std::experi...s_swappable,(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

πŸ’– 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. (1) β€” if the expressions ranges::swap(std::declval<T>(), std::declval<U>()) and ranges::swap(std::declval<U>(), std::declval<T>()) are both well-formed when treated as an unevaluated operand, it provides the member constant value equal to true. otherwise, value is false. access checks are performed as if from a context unrelated to either type.
  2. (2) β€” if T is not a referenceable type (i.e., possibly cv-qualified void or a function type with a cv-qualifier-seq or a ref-qualifier), it provides a member constant value equal to false. otherwise, it provides a member constant value equal to ranges::is_swappable_with<T&, T&>::value.
  3. (3) β€” same as (1), but evaluations of both expressions from (1) are known not to throw exceptions.
  4. (4) β€” same as (2), but uses is_nothrow_swappable_with.
bestie, listen: T and U shall 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 β€” true if T is swappable with U, false otherwise. it’s a [static] public static member constant ✨

πŸŽ€ Member functions πŸŽ€

  • operator bool β€” converts the object to bool, returns value (public member function)
  • operator() β€” (C++14) returns value (public member function)

🌸 Member types 🌸

  • value_type β€” bool
  • type β€” 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