swap(std::expected)(3)
π swap(std::expected) π
okay so this is the C++ Standard Libary manual page for swap(std::expected) β yes bestie, thatβs the manual name, and weβre getting into it π
β¨ NAME β¨
swap(std::expected) β swap(std::expected). Thatβs the name, thatβs the vibe, and honestly? Slay.
π¦ Synopsis π¦
friend constexpr void swap( expected& lhs, expected& rhs )
(since C++23)
noexcept(/*see below*/);
So it overloads the std::swap algorithm for std::expected. It exchanges the state of lhs with that of rhs. Effectively calls lhs.swap(rhs). β¨
This overload participates in overload resolution only if lhs.swap(rhs) is valid. No cap.
This function is not visible to ordinary unqualified or qualified lookup, and can only be found by argument-dependent lookup when std::expected<T, E> is an associated class of the arguments. iykyk π«Ά
πΈ Parameters πΈ
lhs,rhsβexpectedobjects whose states to swap. Two besties, one state exchange π
π Return value π
(none) β literally nothing comes back, bestie. The swap happens in place. π«Ά
π«Ά Exceptions π«Ά
the noexcept specification is:
noexcept(noexcept(lhs.swap(rhs)))
and thatβs the whole exception situation, periodt.
π¦ Example π¦
This section is incomplete π« Reason: no example
π₯ See also π₯
swapβ exchanges the contents; itβs a public member function. Iconic behavior tbh π
π Categories π
conditionally noexceptTodo no example
source: http://cppreference.com Β· version/date: 2024.06.10 Β· page: swap(std::expected)(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