std::experi...const::swap(3)
π NAME
Okay bestie, welcome to the C++ Standard Libary manual β yes, βLibaryβ, weβre keeping the typoβs main character energy β this is the page for std::experi...const::swap(3).
The name line is std::experimental::propagate_const::swap - std::experimental::propagate_const::swap β same thing twice, and honestly? iconic. Itβs a swap for propagate_const. We love a self-titled legend.
β¨ Synopsis
Two version-flavored synopsis bites, bestie π:
constexpr void swap( propagate_const & pt ) (library fundamentals TS v2)
noexcept(/* see below */);
This swaps the wrapped pointer with the one in pt. Let t_ be the private data member that is the wrapped pointer-like object β then this function is equivalent to swap(t_, pt.t_). Overload resolution for swap happens among std::swap and any declaration found by the usual lookup rules, as described in Swappable.
Real talk: behavior is undefined if lvalues ofTdo not satisfySwappable. Not βmessyβ, not βa little offβ β undefined. Do not test that vibe. π
π«Ά Parameters
ptβ anotherpropagate_constobject to swap with. Simple as that, bestie.
π Exceptions
The noexcept specification, for (library fundamentals TS v2):
noexcept(noexcept(swap(t_, pt.t_)))
The lookup for the identifier swap in the exception specification finds the overloads described above and does not find the member function itself, which makes the exception specification equivalent to C++17 std::is_nothrow_swappable.
The noexcept specification, for (library fundamentals TS v3):
noexcept(std::is_nothrow_swappable_v<T>)
π§ Defect reports
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
- DR
LWG 3413β Applied to:LFTSv2. Behavior as published: the exception specification was ill-formed. Correct behavior: made well-formed. Slay for fixes. π
π Category
conditionally noexceptβ thatβs the category, bestie.
Source/version shoutout: http://cppreference.com, dated 2024.06.10, and this page is std::experi...const::swap(3). 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