This week I learned that assigning a constant reference to a temporary will extend the temporary’s lifetime. This is why const std::string &s = Foo(); works.