Namespaces
Variants

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

From cppreference.net
Metaprogramming library
Type traits
Type categories
(C++11)
(C++11) ( DR* )
Type properties
(C++11)
(C++11)
(C++14)
(C++11) (deprecated in C++26)
(C++11) ( until C++20* )
(C++11) (deprecated in C++20)
(C++11)
Type trait constants
Metafunctions
(C++17)
Supported operations
is_move_assignable is_trivially_move_assignable is_nothrow_move_assignable
(C++11) (C++11) (C++11)

Relationships and property queries
Type modifications
Type transformations
(C++11) (deprecated in C++23)
(C++11) (deprecated in C++23)
(C++11)
(C++11) ( until C++20* ) (C++17)

Compile-time rational arithmetic
Compile-time integer sequences
헤더 파일에 정의됨 <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부터)
타입 특성 멤버 상수 value 의 값
T 참조 가능 타입 인 경우 T 가 참조 가능 타입이 아닌 경우
(1) std:: is_assignable < T & , T && > :: value false
(2) std:: is_trivially_assignable < T & , T && > :: value
(3) std:: is_nothrow_assignable < T & , T && > :: value

만약 T 가 완전한 타입이 아니거나, (cv 한정자가 있을 수 있음) void , 또는 알려지지 않은 크기의 배열인 경우, 동작은 정의되지 않습니다.

템플릿의 인스턴스화가 직접적 또는 간접적으로 불완전한 타입에 의존하고, 해당 타입이 가상적으로 완성되었을 때 인스턴스화 결과가 달라질 수 있는 경우, 그 동작은 정의되지 않습니다.

프로그램이 이 페이지에 설명된 템플릿들 중 어느 것에 대해 특수화를 추가하는 경우, 동작은 정의되지 않습니다.

목차

헬퍼 변수 템플릿

template < class T >

inline constexpr bool is_move_assignable_v =

is_move_assignable < T > :: value ;
(C++17부터)
template < class T >

inline constexpr bool is_trivially_move_assignable_v =

is_trivially_move_assignable < T > :: value ;
(C++17부터)
template < class T >

inline constexpr bool is_nothrow_move_assignable_v =

is_nothrow_move_assignable < T > :: value ;
(C++17부터)

std:: integral_constant 로부터 상속됨

멤버 상수

value
[static]
true 만약 T 가 이동 할당 가능한 경우, false 그렇지 않은 경우
(public static member constant)

멤버 함수

operator bool
객체를 bool 로 변환, value 반환
(public member function)
operator()
(C++14)
value 반환
(public member function)

멤버 타입

타입 정의
value_type bool
type std:: integral_constant < bool , value >

가능한 구현

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> {};

참고 사항

특성 std::is_move_assignable MoveAssignable 보다 덜 엄격합니다. 왜냐하면 할당 연산의 결과 타입(이는 MoveAssignable 타입의 경우 T& 이어야 함)을 확인하지 않으며, 할당 후 대상의 값이 할당 전 소스의 값과 동등해야 한다는 의미론적 요구사항도 검사하지 않기 때문입니다.

이 특성을 충족하기 위해 타입이 move assignment operator 를 구현할 필요는 없습니다; 자세한 내용은 MoveAssignable 를 참조하십시오.

예제

#include <iostream>
#include <string>
#include <type_traits>
struct Foo { int n; };
struct NoMove
{
    // prevents implicit declaration of default move assignment operator
    // however, the class is still move-assignable because its
    // copy assignment operator can bind to an rvalue argument
    NoMove& operator=(const NoMove&) { return *this; }
};
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 trivially move-assignable? "
              << std::is_trivially_move_assignable<Foo>::value << '\n'
              << "NoMove is move-assignable? "
              << std::is_move_assignable<NoMove>::value << '\n'
              << "NoMove is nothrow move-assignable? "
              << std::is_nothrow_move_assignable<NoMove>::value << '\n';
}

출력:

std::string is nothrow move-assignable? true
int[2] is move-assignable? false
Foo is trivially move-assignable? true
NoMove is move-assignable? true
NoMove is nothrow move-assignable? false

결함 보고서

다음의 동작 변경 결함 보고서들은 이전에 발표된 C++ 표준에 소급 적용되었습니다.

DR 적용 대상 게시된 동작 올바른 동작
LWG 2196 C++11 T && 가 형성될 수 없는 경우 동작이 불명확했음 이 경우 생성되는 값은 false

참고 항목

특정 인자에 대한 할당 연산자를 가지는지 검사합니다
(클래스 템플릿)
복사 할당 연산자를 가지는지 검사합니다
(클래스 템플릿)