Namespaces
Variants

std:: is_swappable_with, std:: is_swappable, std:: is_nothrow_swappable_with, std:: is_nothrow_swappable

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_swappable_with is_swappable is_nothrow_swappable_with is_nothrow_swappable
(C++17) (C++17) (C++17) (C++17)

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, class U >
struct is_swappable_with ;
(1) (C++17부터)
template < class T >
struct is_swappable ;
(2) (C++17부터)
template < class T, class U >
struct is_nothrow_swappable_with ;
(3) (C++17부터)
template < class T >
struct is_nothrow_swappable ;
(4) (C++17부터)
1) 다음 표현식들 swap ( std:: declval < T > ( ) , std:: declval < U > ( ) ) swap ( std:: declval < U > ( ) , std:: declval < T > ( ) ) using std:: swap ; 선언 후에( Swappable 참조) 평가되지 않은 문맥에서 모두 형성이 잘 된다면, 멤버 상수 value true 로 설정합니다. 그렇지 않으면, value false 입니다.
Access checks 는 어느 타입과도 관련 없는 컨텍스트에서 수행되는 것처럼 진행됩니다.
3) (1) 과 동일하지만, (1) 의 두 표현식 평가 모두 예외를 발생시키지 않는 것으로 알려져 있습니다.
타입 특성 멤버 상수 value 의 값
T 참조 가능 타입 인 경우 T 가 참조 가능 타입이 아닌 경우
(2) std :: is_swappable_with < T & , T & > :: value false
(4) std :: is_nothrow_swappable_with < T & , T & > :: value

만약 T 또는 U 가 완전한 타입이 아니거나, (cv-qualified일 수 있는) void , 또는 unknown bound의 배열인 경우, 동작은 정의되지 않습니다.

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

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

목차

헬퍼 변수 템플릿

template < class T, class U >
inline constexpr bool is_swappable_with_v = is_swappable_with < T, U > :: value ;
(C++17부터)
template < class T >
inline constexpr bool is_swappable_v = is_swappable < T > :: value ;
(C++17부터)
template < class T, class U >

inline constexpr bool is_nothrow_swappable_with_v =

is_nothrow_swappable_with < T, U > :: value ;
(C++17부터)
template < class T >

inline constexpr bool is_nothrow_swappable_v =

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

std:: integral_constant 로부터 상속됨

멤버 상수

value
[static]
true 만약 T U 와 교환 가능한 경우, 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 >

참고 사항

이 특성은 swap 표현식의 직접적인 문맥 외부의 어떤 것도 검사하지 않습니다: T 또는 U 의 사용이 템플릿 특수화, 암시적으로 정의된 특수 멤버 함수의 생성 등을 트리거하고, 그것들에 오류가 있는 경우, 실제 swap은 std :: is_swappable_with < T, U > :: value 가 컴파일되어 true 로 평가되더라도 컴파일되지 않을 수 있습니다.

예제

참고 항목

두 객체의 값을 교환
(함수 템플릿)
타입이 이동 대입 연산자를 가지는지 확인
(클래스 템플릿)
타입이 교환 가능하거나 두 타입이 서로 교환 가능함을 명시
(컨셉)