std::experi...const::swap(3)

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

πŸ’– 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 of T do not satisfy Swappable. Not β€œmessy”, not β€œa little off” β€” undefined. Do not test that vibe. 😭

🫢 Parameters

  • pt β€” another propagate_const object 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