Take the following code:
const std::string GetString()
{
return std::string();
}
auto& thisIsANewString = GetString();
What happens in this scenario? It compiles successfully, but does the auto reference keep the string around? Or does it get destroyed and I'm left with an orphaned reference?
The reason I'm giving this a go is to maintain the const on the return value, whereas just doing a straight auto usage takes a copy.