全部书籍

专业

应用 关于 Coach 登录 开始阅读

书籍暂未推出简体中文版——当前显示英文版。

Computer Science · 术语表

什么是 Move constructor, move assignment, moved-from object?

又称: move constructor · move assignment operator · moved-from object

Definition 2.8 University Computer Science — Year 2 · 第 2 章 — Copying, Moving and Smart Pointers

The move constructor T(T &&o) and the move assignment operator T &operator=(T &&o) build or assign from an rvalue by taking o’s resources rather than copying them. Afterwards o is a moved-from object: it must still be valid, which means it can be destroyed and assigned a new value, but its value is unspecified unless its class documents it.

A move copies the two members of a into c and then empties a, so that exactly one object owns the block. Nothing is allocated, and the cost does not depend on the length of the text.
A move copies the two members of a into c and then empties a, so that exactly one object owns the block. Nothing is allocated, and the cost does not depend on the length of the text.
在原文中阅读 →