std::basic_ios::swap(3)

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

πŸ’– std::basic_ios::swap(3) πŸ’–

okay so bestie, this is the std::basic_ios::swap(3) page from the C++ Standard Libary manual, and we're about to get into a very specific little state-swap situation 🫢


πŸ’– NAME πŸ’–

std::basic_ios::swap - std::basic_ios::swap

like, that's the name, that's the function, no notes ✨

🌸 Synopsis 🌸

It's protected, and it's been around (since C++11):

          protected:                               (since C++11)
          void swap( basic_ios& other ) noexcept;

So what does it actually do? It exchanges the states of *this and other, except for the associated rdbuf objects. The way that works: rdbuf() and other.rdbuf() return the same values as before the call. periodt.

This swap function is protected: it is called by the swap member functions of the derived stream classes such as std::basic_ofstream or std::basic_istringstream, which know how to correctly swap the associated streambuffers. so it's giving "backstage pass only" πŸ’…

πŸŽ€ Parameters πŸŽ€

  • other β€” the basic_ios object to exchange the state with. that's the bestie you're swapping vibes with πŸ”

🌈 Return value 🌈

(none) β€” literally no return value, it just does the swap and leaves 😌

πŸ¦‹ See also πŸ¦‹

  • move β€” moves from another std::basic_ios except for rdbuf (C++11) (protected member function). iconic little relocation moment πŸ‘‘

okay bye bestie πŸ’– β€” source: http://cppreference.com, version/date: 2024.06.10.

πŸ“¦ where this page comes from