std::is_move_constructible, std::is_trivially_move_constructible, std::is_nothrow_move_constructible – cppreference.com
Aus cppreference.com
<metanoindex/>
<tbody> </tbody>
| definiert in Header <type_traits> |
||
|
|
(1) | (seit C++11) |
|
|
(2) | (seit C++11) |
|
|
(3) | (seit C++11) |
1)
Prüft, ob eine Art MoveConstructible ist, dh eine zugängliche explizite oder implizite move Konstruktor. Wenn die Bedingung erfüllt ist, ein Mitglied konstanten value gleich true bereitgestellt wird, sonst value ist false .
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.
2)
Gleiche wie 1), aber der Umzug Konstruktor Ausdruck nicht nennen jede Operation, die nicht trivial ist .
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.
3)
Wie 1), aber die Bewegung Konstruktor Expression 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.
Inherited from std::integral_constant
Member constants
Original:
The text has been machine-translated via Google Translate. (public static Mitglied konstanten) | |
Member functions
wandelt das Objekt Original: converts the object to The text has been machine-translated via Google Translate. (öffentliche Elementfunktion) | |
Member types
Type Original: Type The text has been machine-translated via Google Translate. |
Definition |
value_type
|
bool
|
type
|
std::integral_constant<bool, value>
|
Notes
Verschieben Konstruktoren werden in der Regel noexcept, da sie sonst unbrauchbar jeder Code, der starke Ausnahme Garantie bietet, sind .
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.
Mögliche Implementierung
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> {};
Beispiel
#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
Siehe auch
(C++11) |
prüft, ob ein Typ hat einen Konstruktor für Argumente Original: checks if a type has a constructor for specific arguments The text has been machine-translated via Google Translate. (Klassen-Template) [edit] |
prüft, ob ein Typ hat einen Default-Konstruktor Original: checks if a type has a default constructor The text has been machine-translated via Google Translate. (Klassen-Template) [edit] | |
(C++11) |
prüft, ob ein Typ hat einen Copy-Konstruktor Original: checks if a type has a copy constructor The text has been machine-translated via Google Translate. (Klassen-Template) [edit] |
(C++11) |
erhält eine rvalue Referenz, wenn der Umzug Konstruktor nicht werfen wird Original: obtains an rvalue reference if the move constructor does not throw The text has been machine-translated via Google Translate. (Funktions-Template) [edit] |