Frei Otto s Airborne

Copy-on-write semantics c

Move semantics does not return a "fake" copy. Instead, in a copy operation, it gives the copyee permission to trash the original copy.

A motivating example may be instructive:

std::vector bigData; // fill bigData std::vector listOfData; listOfData.push_back(std::move(bigData)); // after this point, the contents of bigData are unspecified (however accessing it is _not_ undefined behavior)

Without move semantics, you'd need to copy bigData to insert it into listOfData, or manually twiddle with swap into a new empty vector that's in listOfData. But with move semantics, the rvalue-reference-constructor (aka move constructor) of std::vector, invoked by push_back as it copies in the new data, has permission to trash the old contents of bigData - thus, it's allowed to steal bigData's internal pointer and reset bigData to an empty vector, for example.

Move semantics are usually faster than COW semantics as they don't need to maintain reference counts to shared, read-only data. They are, however, more limited - you can't create multiple reference-counted aliases to your data with move semantics, you can just easily and conveniently shuffle data between containers.

Also note that both recent versions of GCC and Microsoft Visual C++ support rvalue references and move semantics (GCC with -std=c++0x), so there's no reason not to start using them today.

See also:
  • compare prices
Yifangya Makis Bens Case for iPhone 5/5S BralnStructufeAmdFunctien Bmc Neuroscience Full Text Symbiotic Relationship Between Bimonthly Journals
Wireless (Yifangya)
  • Quality pictures printed onto the back of cover case.
  • Custom molded to the shape of your Apple iPhone 5/5S.
  • Strong durable plastic with light weight.
  • Constructed from high quality materials.
  • Protects your phone from scratches and accidental bumps.
Related Posts