I heard the temporary objects can only be assigned to constant references.
But this code gives error
#include
template
Your code gives error because the const
qualifier in const ref error
is just ignored because 8.3.2/1
says
Cv-qualified references are ill-formed except when the cv-qualifiers are introduced through the use of a typedef (7.1.3) or of a template type argument(14.3), in which case the cv-qualifiers are ignored.`
So error
has type int&
not const int&
.