【发布时间】:2011-04-21 19:31:05
【问题描述】:
移动一个物体后,它必须是可破坏的:
T obj;
func(std::move(obj));
// don't use obj and let it be destroyed as normal
但是 obj 还能做什么呢?你能把另一个物体移进去吗?
T obj;
func(std::move(obj));
obj = std::move(other);
这是否取决于确切的类型? (例如,std::vector 可以为所有 T 做出您不能依赖的特定保证。)除了对移动对象的破坏之外,所有类型是否都支持某些东西是必需的,甚至是理智的?
【问题讨论】:
标签: c++ c++11 move-semantics