Namespaces
Variants
Views
Actions

Difference between revisions of "cpp/named req/MoveAssignable"

From cppreference.com
< cpp‎ | named req
(Requirements: return type)
Line 10: Line 10:
 
{{member | 1={{dcl small|Type::}}operator= | 2=
 
{{member | 1={{dcl small|Type::}}operator= | 2=
  
{{ddcl | 1=Type::operator=( Type&& other )}}
+
{{ddcl | 1=R Type::operator=( Type&& other )}}
  
 
[[cpp/language/move_operator|Move assignment operator]]: assigns the contents of {{tt|other}}. The internal state of {{tt|other}} is unspecified after the move. However, it must still be valid, that is, no invariants of the type are broken.
 
[[cpp/language/move_operator|Move assignment operator]]: assigns the contents of {{tt|other}}. The internal state of {{tt|other}} is unspecified after the move. However, it must still be valid, that is, no invariants of the type are broken.
 +
 +
There is no requirements the return type {{tt|R}}, but usually the returned type is {{tt|Type&}} and the function returns {{cpp|*this}}.
  
 
The following expressions must have the specified effects:
 
The following expressions must have the specified effects:

Revision as of 05:53, 11 March 2012

Template:cpp/concept/title Template:cpp/concept/sidebar

Specifies that an instance of the type can be move-assigned (moved). This means that type has move semantics: that is, can transfer its internal state to another instance of the same type with minimal overhead.

Requirements

The type must implement the following functions:

Type::operator=

R Type::operator=( Type&& other )

Move assignment operator: assigns the contents of other. The internal state of other is unspecified after the move. However, it must still be valid, that is, no invariants of the type are broken.

There is no requirements the return type R, but usually the returned type is Type& and the function returns Template:cpp.

The following expressions must have the specified effects:

Template:tdcl list begin Template:tdcl list hitem Template:tdcl list item Template:tdcl list end