The example code is taken from: http://en.cppreference.com/w/cpp/types/add_cv (I modified a little.)
struct foo
{
void m() { std::cout << "Non-cv\n"; }
void m() const { std::cout << "Const\n"; }
};
template<class T>
void call_m()
{
T().m();
}
int main()
{
call_m<foo>();
call_m<const foo>(); //here
}
And the output is:
Non-cv
Non-cv
in the second call, T
is const qualified, so T()
should call the const version, right? or are there some special rules I missed?