std::experi...s_swappable,(3)
π NAME π
hey bestie! welcome to std::experi...s_swappable,(3) from the C++ Standard Libary manual set π. this page is serving these trait names:
std::experimental::ranges::is_swappable_with,std::experimental::ranges::is_swappable,
-
std::experimental::ranges::is_swappable_with,std::experimental::ranges::is_swappable,
yes, it literally lists std::experimental::ranges::is_swappable_with and std::experimental::ranges::is_swappable twice with a - in the middle, and we are not gonna pretend thatβs not a whole vibe π
π¦ Synopsis π¦
first, hereβs the floating line the synopsis starts with:
std::experimental::ranges::is_nothrow_swappable
then it drops the header and declarations like this:
Defined in header <experimental/ranges/type_traits>
template< class T, class U > (1) (ranges TS)
struct is_swappable_with;
template< class T > (2) (ranges TS)
struct is_swappable;
template< class T, class U > (3) (ranges TS)
struct is_nothrow_swappable_with;
template< class T > (4) (ranges TS)
struct is_nothrow_swappable;
- (1) β if the expressions
ranges::swap(std::declval<T>(), std::declval<U>())andranges::swap(std::declval<U>(), std::declval<T>())are both well-formed when treated as an unevaluated operand, it provides the member constantvalueequal totrue. otherwise,valueisfalse. access checks are performed as if from a context unrelated to either type. - (2) β if
Tis not a referenceable type (i.e., possibly cv-qualifiedvoidor a function type with a cv-qualifier-seq or a ref-qualifier), it provides a member constantvalueequal tofalse. otherwise, it provides a member constantvalueequal toranges::is_swappable_with<T&, T&>::value. - (3) β same as (1), but evaluations of both expressions from (1) are known not to throw exceptions.
- (4) β same as (2), but uses
is_nothrow_swappable_with.
bestie, listen:TandUshall each be a complete type, (possibly cv-qualified)void, or an array of unknown bound. otherwise, the behavior is undefined. not cute, not slay, just undefined π
π Member constants π
valueβtrueifTis swappable withU,falseotherwise. itβs a[static]public static member constant β¨
π Member functions π
operator boolβ converts the object tobool, returnsvalue(public member function)operator()β(C++14)returnsvalue(public member function)
πΈ Member types πΈ
value_typeβbooltypeβstd::integral_constant<bool, value>
π§ Notes π§
this trait does not check anything outside the immediate context of the swap expressions: if the use of T or U would trigger template specializations, generation of implicitly-defined special member functions etc, and those have errors, the actual swap may not compile even if ranges::is_swappable_with<T,U>::value compiles and evaluates to true. like, the trait can say yes while the actual swap still faceplants π
π Example π
it is literally this, bestie:
This section is incomplete
Reason: no example
no example, just vibes π
π See also π
Swappable,SwappableWithβ specifies that a type can be swapped or that two types can be swapped with each other (concept)is_swappable_with(C++17),is_swappable(C++17),is_nothrow_swappable_with(C++17),is_nothrow_swappable(C++17)β checks if objects of a type can be swapped with objects of same or different type (class template)
β Category β
Todo no example
okay thatβs the whole page, bestie π«Ά β it lives at http://cppreference.com, dated 2024.06.10, and itβs std::experi...s_swappable,(3). mwah πβ¨
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms