Концепции C++: MoveAssignable (начиная с C++11)
Материал из cppreference.com
|
|
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
Указывает, что экземпляр типа могут двигаться назначенный (перемещен). Это означает, что тип имеет движение семантики, то есть может передать свое внутреннее состояние на другой экземпляр того же типа, потенциально уменьшая накладные расходы.
Original:
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 potentially minimizing the overhead.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
[править] Требования
Типа должны соответствовать требованиям
CopyAssignable и / или осуществлять следующие функции:Original:
The type must meet
CopyAssignable requirements and/or implement the following functions:The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Type::operator=
| Type& Type::operator=( Type&& other ); Type& Type::operator=( const Type&& other ); |
(Одним из вариантов является достаточным) | |
Переместите оператор присваивания: 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. The function must return *this.
The following expressions must have the specified effects:
| Выражение
Original: Expression The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
Effects |
| a = rv; | a эквивалентно rv, где a является экземпляром Type и rv является RValue ссылки из Type .Original: The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
[править] См. также
| (C++11) (C++11) (C++11) |
проверяет, является ли тип имеет оператор ход назначения Original: checks if a type has a move assignment operator The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (шаблон класса) |