kand k2are types const int&.
Here is a complete list of types. Note that the top level is constdiscarded for type inference auto.
int main()
{
const int i = 42;
auto j = i;
const auto &k = i;
auto *p = &i;
const auto j2 = i, &k2 = i;
}
Finally, if you wrote
auto q = &k2;
q const int*, const , , auto . , .
j2 k2 , , - , , . ,
const int j2 = i, &k2 = i;
, ++ 11 is_same:
.
bool am_I_the_same = std::is_same<decltype(k2), const int&)::value
decltype .
: http://en.cppreference.com/w/cpp/types/is_same