std::string() - typeid. - .
In the template argument, if there is ambiguity between the type identifier and the expression, the call is allowed to the type identifier. So your code outputs 1
You need to remove the parentheses ()to get 2 as the result ie foo<std::string>()will give you an output of 2.
source
share