std::is_move_assignable, std::is_trivially_move_assignable, std::is_nothrow_move_assignable

From Cppreference

Jump to: navigation, search
Defined in header <type_traits>

template< class T >
struct is_move_assignable;
(1) (C++11 feature)
template< class T >
struct is_trivially_move_assignable;
(2) (C++11 feature)
template< class T >
struct is_nothrow_move_assignable;
(3) (C++11 feature)

1) If the move-assignment expression std::declval<T&>() = std::declval<T&&>() is well-formed in unevaluated context, provides the member constant value equal true. For any other type, value is false.

2) same as 1), but evaluation of the move-assignment expression will not call any operation that is not trivial.

3) same as 1), but the evaluation of the move-assignment expression will not call any operation that is not noexcept.

Contents

Inherited from std::integral_constant

Member constants

value true if T is move-assignable, false otherwise
(public static member constant)

Member functions

operator bool converts the object to bool, returns value
(public member function)

Member types

Type Definition
value_type bool
type std::integral_constant<bool, value>

[edit] Equivalent definition

[edit] Example

#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

[edit] See also

is_assignable
is_trivially_assignable
is_nothrow_assignable
(C++11)
(C++11)
(C++11)
checks if a type has a assignment operator for a specific argument
(class template)
is_copy_assignable
is_trivially_copy_assignable
is_nothrow_copy_assignable
(C++11)
(C++11)
(C++11)
checks if a type has a copy assignment operator
(class template)