-
Milian Wolff authored
The type of all a* declarations below is just "int" without any reference or const in them, as you can verify by reading this article: http://cpp-next.com/archive/2011/04/appearing-and-disappearing-consts-in-c/ Alternatively compile and run this simple test app: ~~~ #include <iostream> #define tryAssignAutoType(x) \ { \ std::cout << "original: " << x << std::endl; \ auto a = x; \ ++a; \ std::cout << "after: " << x << ", a: " << a << std::endl; \ } int main() { int i = 0; const int& iConstRef = i; tryAssignAutoType(iConstRef) int& iRef = i; tryAssignAutoType(iRef) const int iConst = i; tryAssignAutoType(iConst) int&& iRefRef = std::move(i); tryAssignAutoType(iRefRef) return 0; } ~~~ The output is: ~~~ original: 0 after: 0, a: 1 original: 0 after: 0, a: 1 original: 0 after: 0, a: 1 original: 0 after: 0, a: 1 ~~~
1d0079f4