The following code is excerpted from cppreference.com.
#include
#include
struct foo
{
void m() { std::cout <<
From what i remember it goes as follows, you can write 3 consts(3 is the number of purpose) in a function declaration.
before the return type, after the function and its parameters, and on the parameters themselves.
const at the end of a function signature means that the function should assume the object of which it is a member is const. In practical terms it means that you ask the compiler to check that the member function does not change the object data in any way. It means asking the compiler to check that it doesn't directly change any member data, and it doesn't call any function that itself does not guarantee that it won't change the object.
before the return type means the thing the function is to return should be a const.
const parameter means that the parameter cannot be changed.
so the difference here is, the first call is not a const so it goes to the "non-cv", the second call is a const and so goes to "const".
what i think of why VC++ goes to the same function both times is that call_m explicitly calls for T().m() thinking it shouldnt go to the const one.