std::is_move_constructible, std::is_trivially_move_constructible, std::is_nothrow_move_constructible
提供: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_constructible; |
(1) | (C + + 11以来) |
| template< class T > struct is_trivially_move_constructible; |
(2) | (C + + 11以来) |
| template< class T > struct is_nothrow_move_constructible; |
(3) | (C + + 11以来) |
タイプは
2) MoveConstructibleであるかどうかをチェックし、すなわちアクセス可能な明示的または暗黙的なムーブコンストラクタを持っています。要件が満たされている場合、メンバーは、一定value等しいtrueが提供され、そうでなければvaluefalseです.Original:
Checks whether a type is
MoveConstructible, i.e. has an accessible explicit or implicit move constructor. 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 the move constructor expression does 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 move constructor expression is 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 [静的] |
true T is move-constructible もし、そうでなければfalse Original: true if T is move-constructible , 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> |
[編集] ノート
そうでなければ、彼らは強い例外保証を提供する任意のコード内で使用できなくなりますので、移動コンストラクタは通常、noexceptアール.
Original:
Move constructors are usually noexcept, since otherwise they are unusable in any code that provides strong exception guarantee.
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.
[編集] 可能な実装
template<class T> struct is_move_constructible : std::is_constructible<T, typename std::add_rvalue_reference<T>::type> {}; template<class T> struct is_trivially_move_constructible : std::is_trivially_constructible<T, typename std::add_rvalue_reference<T>::type> {}; template<class T> struct is_nothrow_move_constructible : std::is_nothrow_constructible<T, typename std::add_rvalue_reference<T>::type> {}; |
[編集] 例
#include <iostream> #include <type_traits> struct Ex1 { std::string str; // member has a non-trivial but non-throwing move ctor }; struct Ex2 { int n; Ex2(Ex2&&) = default; // trivial and non-throwing }; int main() { std::cout << std::boolalpha << "Ex1 is move-constructible? " << std::is_move_constructible<Ex1>::value << '\n' << "Ex1 is trivially move-constructible? " << std::is_trivially_move_constructible<Ex1>::value << '\n' << "Ex1 is nothrow move-constructible? " << std::is_nothrow_move_constructible<Ex1>::value << '\n' << "Ex2 is trivially move-constructible? " << std::is_trivially_move_constructible<Ex2>::value << '\n' << "Ex2 is nothrow move-constructible? " << std::is_nothrow_move_constructible<Ex2>::value << '\n'; }
Output:
Ex1 is move-constructible? true Ex1 is trivially move-constructible? false Ex1 is nothrow move-constructible? true Ex2 is trivially move-constructible? true Ex2 is nothrow move-constructible? true
[編集] も参照してください
| (C++11) (C++11) (C++11) |
タイプかどうかをチェックするには、特定の引数のコンストラクタを持っています Original: checks if a type has a constructor for specific arguments The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (クラステンプレート) |
| タイプかどうかをチェックするには、デフォルトコンストラクタを持っています Original: checks if a type has a default constructor 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 constructor The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (クラステンプレート) |
| (C++11) |
ムーブコンストラクタがスローされない場合、右辺値参照を取得します Original: obtains an rvalue reference if the move constructor does not throw The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) |