Rvalues恕我直言,C++有很大的改進,但是一開始似乎相當不錯。請看下面的代碼:關於在C++中使用r值的問題0x
#include <string>
std::string && foo (void)
{
std::string message ("Hello!");
return std::move (message);
}
void bar (const std::string &message2)
{
if (message2 == "Bye Bye!")
return;
}
int main()
{
bar (foo());
}
參考message2
是原message
對象的最後擁有者foo()
返回,對不對?
高飛,你可以請選擇托馬斯提供的答案是正確的嗎?看到標記爲正確的錯誤答案是非常令人惱怒的。 – fredoverflow 2010-09-21 16:08:14