Are int& and int the same type? if I use is_same<int,int&>::value i get false but typeid(int).name() == typeid(int&).name() are the same?
secondly the same question for int and const int?
Thirdly int and int*?
I can understand if int and int* are not as one actually stores the address of another object and works differently but I would have thought int& and int are as one is just an alias for another.
Keen to get some good commentary on this.
From Paragraph 5.2.7/4 of the C++11 Standard:
Thus,
typeid(int)andtypeid(int&)will give the same result, although the two types are definitely different. Similarly, for the type systemintandint constare different types, but thetypeidoperator ignores theconstqualification. From Paragraph 5.2.7/5 of the C++11 Standard:Finally,
intandint*are again different types for the type system, and thetypeidoperator returns different results for them.