Alle boeken

Professioneel

Apps Over Coach Inloggen Begin met lezen

Computer Science · Begrippenlijst

Wat is Move constructor, move assignment, moved-from object?

Ook bekend als: move constructor · move assignment operator · moved-from object

Definition 2.8 University Computer Science — Year 2 · Hoofdstuk 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.
Lees in het hoofdstuk →