I have the following typedef:
using int_ref = int&&;
Why does the following code not produce an error (or print false)?
std::cout << is_same< int_ref, int_ref&& >::value; // prints 1
I would expect that int_ref&& gets expanded to int&& && which is obviously not possible. Am I missing something?
This is due to reference collapsing rules.
Basically, although you can't write a reference to a reference yourself, in some cases (typedefs, template parameters, decltypes) you can add create a reference to a reference type, which collapses as follows:
In your case,
int_refisint&&, soint&& &&becomesint&&.The relevant standard quote: