Does returning by const value affect return value optimization? [duplicate]
问题 This question already has answers here : Can a C++ compiler perform RVO for a const return value? (1 answer) Purpose of returning by const value? [duplicate] (4 answers) Closed 5 years ago . Consider the function const std::string f() { return "hello"; } And the call std::string x = f(); Regardless of whether value return types should be const or not, does the fact the return value is const, prevent a compiler from performing return value optimization? My understanding of RVO is that the