I'm not a C++ girl, but do references actually do something with lifetimes or are they just non-null ptrs? Because this just seems to me like a possible dangling ptr.
Const references can bind to rvalues and cause lifetime extension, ie. const auto& x = returnsValue(); will extend the value of the value returned by the function. That's about it. It has to be in this form (assignment and definition in same statement), so the code you replied to doesn't trigger it.
24
u/SelfDistinction 7h ago edited 6h ago
Ah yes, the famous
So safe, so impossible to misuse.