#include <iostream>
using namespace std;
int main() {
//int& a = 3; <- Doesn't compile. Expression must be lvalue.
const auto& c = 1 + 2; // c is a constant reference to an int. (?)
// compiles fine. 1+2 is a rvalue? what's going on?
cout << c << endl;
return 0;
}
I don't understand why the compiler wont raise a compilation error. Since auto "forces" c to be a reference to a constant int, and references are refereed to lvalues, how come this works?