Why is the following not an error?
const auto& foo = std::string("foo");
In my mental model of C++ I think of references as glorified non-null pointers that the language wraps in syntactic sugar for me. However the code below would be an error but the above is not.
const auto* foo = &(std::string("foo"));
In the reference case why is the string not immediately destructed after the r-value expression is evaluated?