| Type traits | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Compile-time rational arithmetic | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Compile-time integer sequences | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
(C++14) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Defined in header <type_traits> | ||
template<class T,class U> struct is_swappable_with; | (1) | (since C++17) |
template<class T> struct is_swappable; | (2) | (since C++17) |
template<class T,class U> struct is_nothrow_swappable_with; | (3) | (since C++17) |
template<class T> struct is_nothrow_swappable; | (4) | (since C++17) |
value equaltrue. Otherwise,value isfalse.| Type trait | The value of the member constantvalue | |
|---|---|---|
T is areferenceable type | T is not a referenceable type | |
| (2) | std::is_swappable_with<T&, T&>::value | false |
| (4) | std::is_nothrow_swappable_with<T&, T&>::value | |
IfT orU is not a complete type, (possibly cv-qualified)void, or an array of unknown bound, the behavior is undefined.
If an instantiation of a template above depends, directly or indirectly, on an incomplete type, and that instantiation could yield a different result if that type were hypothetically completed, the behavior is undefined.
If the program adds specializations for any of the templates described on this page, the behavior is undefined.
Contents |
template<class T,class U> inlineconstexprbool is_swappable_with_v= is_swappable_with<T, U>::value; | (since C++17) | |
template<class T> inlineconstexprbool is_swappable_v= is_swappable<T>::value; | (since C++17) | |
template<class T,class U> inlineconstexprbool is_nothrow_swappable_with_v= | (since C++17) | |
template<class T> inlineconstexprbool is_nothrow_swappable_v= | (since C++17) | |
value [static] | true ifT is swappable withU,false otherwise(public static member constant) |
operator bool | converts the object tobool, returnsvalue (public member function) |
operator() (C++14) | returnsvalue (public member function) |
| Type | Definition |
value_type | bool |
type | std::integral_constant<bool, value> |
This trait does not check anything outside the immediate context of the swap expressions: if the use ofT orU would trigger template specializations, generation of implicitly-defined special member functions etc, and those have errors, the actual swap may not compile even ifstd::is_swappable_with<T, U>::value compiles and evaluates totrue.
| This section is incomplete Reason: no example |
| swaps the values of two objects (function template)[edit] | |
(C++11)(C++11)(C++11) | checks if a type has a move assignment operator (class template)[edit] |
(C++20) | specifies that a type can be swapped or that two types can be swapped with each other (concept)[edit] |