C++ 概念: MoveConstructible (C++11 起)
来自cppreference.com
该页由英文版wiki使用Google Translate机器翻译而来。
该翻译可能存在错误或用词不当。鼠标停留在文本上可以看到原版本。你可以帮助我们修正错误或改进翻译。参见说明请点击这里. |
指定的类型的一个实例可以移动(移动)建造的。这意味着该类型的移动语义:也就是说,可以将其内部状态的相同类型的新实例,有可能最大限度地减少开销.
原文:
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.
[编辑] 要求
类型必须符合
CopyConstructible
要求和/或实现以下功能:原文:
The type must meet
CopyConstructible
requirements and/or implement the following functions: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:
表达
|
Effects |
Type a = rv; | |
Type(rv); |
[编辑] 另请参阅
(C++11) (C++11) (C++11) |
检查对象是否声明了移动构造函数 (类模板) |