C++ 概念: MoveConstructible (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-constructed (moved). This means that type has move semantics: that is, can transfer its internal state to a new 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.
[编辑] 要求
类型必须符合
CopyConstructible要求和/或实现以下功能:Original:
The type must meet
CopyConstructible 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::Type
| Type::Type( Type&& other ); Type::Type( const Type&& other ); |
(的变种之一就足够了) | |
移动的构造函数: constructs an instance of a type with 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 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 |
| Type a = rv; | a相当于rv,其中rv是右值引用的Type.Original: The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
| Type(rv); | Type类型的对象是一个临时相当于rv,rv是一个右值引用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 constructor The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (类模板) |