Todos los libros

Profesional

Apps Acerca de Coach Iniciar sesión Empezar a leer

Computer Science · Glosario

¿Qué es Move constructor, move assignment, moved-from object?

También llamado: move constructor · move assignment operator · moved-from object

Definition 2.8 University Computer Science — Year 2 · Capítulo 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.
Leer en el capítulo →