std::experi...ranges::swap(3)
bestie, welcome to the std::experi...ranges::swap(3) page from the C++ Standard Libary manual β yes, thatβs the headerβs spelling, and weβre rolling with it ππ
π NAME π
std::experimental::ranges::swap β std::experimental::ranges::swap. Thatβs the name, bestie. Full government name. No cap.
β¨ Synopsis β¨
okay so this lives in the header, and itβs giving customization point object main character energy:
Defined in header <experimental/ranges/utility>
namespace {
constexpr /* unspecified */ swap = /* unspecified (ranges TS)
*/;
(customization point object)
}
Call signature
template< class T, class U >
requires /* see below */
void swap( T&& t, U&& u ) noexcept(/* see below */);
ranges::swap exchanges the values referenced by t and u π
A call to ranges::swap is equivalent to:
(void)swap(std::forward<T>(t), std::forward<U>(u)), if that expression is valid, where the overload resolution is performed with the following candidates:template<class T> void swap(T&, T&) = delete;template<class T, std::size_t N> void swap(T(&)[N], T(&)[N]) = delete;- any declarations of
swapfound by argument-dependent lookup.
If the function selected by overload resolution does not exchange the values referenced by t and u, the program is ill-formed; no diagnostic required.
- Otherwise,
(void)ranges::swap_ranges(t, u), ifTandUare lvalue references to array types of equal extent (but possibly different element types) andranges::swap(*t, *u)is a valid expression. - Otherwise, if
TandUare bothV&for some typeVthat meets the syntactic requirements ofMoveConstructible<V>andAssignable<V&, V>, exchanges the referenced values as if byV v{std::move(t)}; t = std::move(u); u = std::move(v);. If the semantic requirements of either concept are not satisfied, the program is ill-formed; no diagnostic required. - In all other cases, a call to
ranges::swapis ill-formed.
ranges::swap can be used in a constant expression if every function it calls (as specified above) can be so used. lowkey iconic β¨
π Exceptions π
the noexcept tea changes depending on which branch you landed in:
noexceptspecification:
noexcept(noexcept((void)swap(std::forward<T>(t),
std::forward<T>(u))))
where swap is found as described above.
noexceptspecification:
noexcept(noexcept(ranges::swap(*t, *u)))
noexceptspecification:
noexcept(std::is_nothrow_move_constructible<V>::value &&
std::is_nothrow_move_assignable<V>::value)
π Example π
this section is literally incomplete, and the reason is right there:
This section is incomplete
Reason: no example
so yeah, no example here, bestie π
π¦ See also π¦
swapβ swaps the values of two objects (function template)
π Categories π
conditionally noexceptTodo no example
source: http://cppreference.com Β· version/date: 2024.06.10 β mwah π bye bestie π«Ά
π¦ 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