std::experi...::optional)(3)

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

πŸ’– NAME πŸ’–

okay bestie, the official name is std::experimental::swap(std::experimental::optional) β€” and the page literally repeats it right after: std::experimental::swap(std::experimental::optional). yes, we love a name that says itself twice πŸ’…βœ¨

This is the std::experi...::optional)(3) page, living in the C++ Standard Libary manual. (That manual name is literally C++ Standard Libary, no cap.) 🫢


✨ Synopsis ✨

First up, the header tea:

Defined in header <experimental/optional>
template< class T >
void swap( optional<T>& lhs, optional<T>& rhs )            (library
fundamentals TS)
noexcept(/* see below */);

So this overloads the std::swap algorithm for std::experimental::optional. It exchanges the state of lhs with that of rhs. Effectively calls lhs.swap(rhs). periodt πŸ’–


🌸 Parameters 🌸

  • lhs, rhs β€” optional objects whose states to swap

like, those are the two cuties whose states are getting swapped, okay? πŸ¦‹


πŸŽ€ Return value πŸŽ€

(none)

literally nothing comes back. it's giving "the swap is the point" energy 😌✨


πŸ”₯ Exceptions πŸ”₯

the noexcept specification is exactly this:

noexcept(noexcept(lhs.swap(rhs)))

ngl that double-noexcept is a whole vibe, but that's the spec bestie πŸ’œ


🧚 Example 🧚

This section is incomplete Reason: no example

no example yet 😭 the page is leaving us on read, fr fr πŸ™ˆ


πŸ’œ See also πŸ’œ

  • swap exchanges the contents β€” (public member function)

iykyk, it's the member-function version of the same "exchange the contents" moment πŸ‘‘


🌈 Categories 🌈

  • Noindexed pages
  • conditionally noexcept
  • Todo no example

mwah πŸ’‹ that's the whole page! it came from http://cppreference.com, dated 2024.06.10, and the footer title is literally std::experi...::optional)(3) β€” bye bestie, slay your optional swaps responsibly πŸ«ΆπŸŽ€πŸ’–

πŸ“¦ where this page comes from