Here I want to know how type specifier decltype
works:
const int& rci = 5;// const ref bound to a temporary
decltype (rci) x = 2;
decltype (rci + 0) y = 10;
// ++x; // error: increment of read-only reference ‘x’|
++y; // why does this work
std::cout << typeid(x).name() << std::endl; // i
std::cout << typeid(y).name() << std::endl; // i
-
Why
y
has only typeint
rather thanconst int
? -
Does converting a constant lvalue into an rvalue discards in addition to reference operator,
const
qualifier too? -
Why
typeid
shows that the type of x is justi
but notconst int&
?
Aucun commentaire:
Enregistrer un commentaire