std::is_move_assignable, std::is_trivially_move_assignable, std::is_nothrow_move_assignable
来自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. |
| Defined in header <type_traits>
|
||
| template< class T > struct is_move_assignable; |
(1) | (C++11 起) |
| template< class T > struct is_trivially_move_assignable; |
(2) | (C++11 起) |
| template< class T > struct is_nothrow_move_assignable; |
(3) | (C++11 起) |
抛出它的参数。检查一个类型是否是
2) MoveAssignable,即有一个可访问的显式或隐式的举动赋值运算符。如果符合要求,一个成员value等于true,否则value是false.Original:
Checks whether a type is
MoveAssignable, i.e. has an accessible explicit or implicit move assignment operator. If the requirement is met, a member constant value equal true is provided, otherwise value is false.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.
1),但评价的移动赋值表达式不会调用任何操作,是不平凡的.
3) Original:
same as 1), but evaluation of the move-assignment expression will not call any operation that is not trivial.
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.
1),但移动赋值表达式的评价不叫任何操作,不noexcept的.
Original:
same as 1), but the evaluation of the move-assignment expression will not call any operation that is not noexcept.
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.
目录 |
Inherited from std::integral_constant
Member constants
| value [静态的] </ SPAN></div></div>
|
true如果 T is move-assignable,false其他方式 Original: true if T is move-assignable, false otherwise The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (公共静态成员常量) |
Member functions
| operator bool |
转换的对象bool,返回 value Original: converts the object to bool, returns value The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (公共成员函数) |
Member types
| 类型
Original: Type The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
Definition |
value_type
|
bool
|
type
|
std::integral_constant<bool, value> |
</div>
[编辑] 可能的实现
template< class T> struct is_move_assignable : std::is_assignable< typename std::add_lvalue_reference<T>::type, typename std::add_rvalue_reference<T>::type> {}; template< class T> struct is_trivially_move_assignable : std::is_trivially_assignable< typename std::add_lvalue_reference<T>::type, typename std::add_rvalue_reference<T>::type> {}; template< class T> struct is_nothrow_move_assignable : std::is_nothrow_assignable< typename std::add_lvalue_reference<T>::type, typename std::add_rvalue_reference<T>::type> {}; |
[编辑] 为例
#include <iostream> #include <string> #include <type_traits> struct Foo { int n; }; int main() { std::cout << std::boolalpha << "std::string is nothrow move-assignable? " << std::is_nothrow_move_assignable<std::string>::value << '\n' << "int[2] is move-assignable? " << std::is_move_assignable<int[2]>::value << '\n' << "Foo is trivally move-assignable? " << std::is_trivially_move_assignable<Foo>::value << '\n'; }
Output:
std::string is nothrow move-assignable? true int[2] is move-assignable? false Foo is trivially move-assignable? true
[编辑] 另请参阅
| (C++11) (C++11) (C++11) |
如果一个类型的检查有特定参数的赋值操作符 Original: checks if a type has a assignment operator for a specific argument 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 copy assignment operator The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (类模板) |