如果我在 C++11 中保持对函数的非引用返回值的常量引用,那么堆栈中的引用点在哪里?这样做安全吗?
string foo() { std::string foo_ret = "foo string"; return foo_ret; } int main() { const std::string& a = foo(); }
c++ reference return-value c++11
c++ ×1
c++11 ×1
reference ×1
return-value ×1