在代码审查中,我发现了一些类似的东西:
std::string foo()
{
char tmp[] = "abcd";
return tmp;
}
字符缓冲区是否在超出范围之前转换为 std::string
?
最佳答案
Is the character buffer converted into a std::string before it gets out of scope ?
是的。返回值在函数返回之前被初始化。
关于c++ - 返回一个返回类型为 `std::string` 的本地字符数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53797259/