[ Web Proxy ]
URL:
Viewing: https://ru.cppreference.com/cpp/types/is_move_assignable [Back]  [Original]

std::is_move_assignable, std::is_trivially_move_assignable, std::is_nothrow_move_assignable cppreference.com
cppreference.com

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

cppreference.com
 
C++
(C++20)
(C++20)
(C++11)
(C++20)
/
(C++11)
(C++11)
(C++11)
(C++17)
 
(C++11)
(C++14)  
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++14)
(C++11)
(C++11)( C++20*)
(C++11)( C++20)
(C++11)
(C++17)
(C++11)(C++11)(C++11)
(C++11)( C++23)
(C++11)( C++23)
(C++11)
(C++11)
(C++17)

(C++11)( C++20*)(C++17)
 
<tbody> </tbody>
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)
1) T , (.., , cv- void cv- ), - value, false. - value, std::is_assignable<T&, T&&>::value.
2) , (1), std::is_trivially_assignable<T&, T&&>
3) , (1), std::is_nothrow_assignable<T&, T&&>

T , (, cv-) void . .

, , , .

, , .

<tbody> </tbody>
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 -)

-

operator bool
bool, value
(public -)
operator()
(C++14)
value
(public -)

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&), , .

, ; MoveAssignable

#include <iostream>
#include <string>
#include <type_traits>
struct Foo { int n; };
struct NoMove {
    //      
    //   ,     ,
    //         
    NoMove& operator=(const NoMove&) { return *this; }
};
int main() {
    std::cout << std::boolalpha
              << "std::string      ? "
              << std::is_nothrow_move_assignable<std::string>::value << '\n'
              << "int[2]    ? "
              << std::is_move_assignable<int[2]>::value << '\n'
              << "Foo     ? "
              << std::is_trivially_move_assignable<Foo>::value << '\n';

    std::cout << std::boolalpha
              << "NoMove    ? "
              << std::is_move_assignable<NoMove>::value << '\n'
              << "NoMove      ? "
              << std::is_nothrow_move_assignable<NoMove>::value << '\n';
}

:

std::string      ? true
int[2]    ? false
Foo     ? true
NoMove    ? true
NoMove      ? false

,
( ) []
,
( ) []

Web Proxy Viewer  |  New URL  |  Original Page