跳转至

Core future of move semantics

Rvalue References

std::move()

std::move()是一个定义在头文件<utility>中的标准库函数,虽然几乎所有标准库文件都包含了<utility>但是仍应该在使用std::move()时包含<utility>使程序具有更好的移植性

std::move()只是一个将值类似转换为右值引用的static_cast,因此,可以使用static_cast实现类似std::move()的效果

foo(static_cast<decltype(obj)&&>(obj)) // same effect as foo(std::move(obj))

评论