std::basic_...m::operator=(3)

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

okay bestie, gather round πŸ’– this is the std::basic_istream::operator= page from the C++ Standard Libary manual β€” page label std::basic_...m::operator=(3), and yes the title is giving main-character energy ✨

πŸŽ€ NAME πŸŽ€

std::basic_istream::operator= β€” std::basic_istream::operator= (the name said it twice and honestly? slay πŸ’…)

✨ Synopsis ✨

          protected:                                                     (1)
          basic_istream& operator=( const basic_istream& rhs ) = delete;
          protected:                                                     (2)
       (since C++11)
          basic_istream& operator=( basic_istream&& rhs );

🌸 Description 🌸

  1. The copy assignment operator is protected, and is deleted. Input streams are not CopyAssignable. So like… copying one? not a thing, bestie πŸ™ˆ
  2. The move assignment operator exchanges the gcount() values and all data members of the base class, except for rdbuf(), with rhs, as if by calling swap(*rhs). This move assignment operator is protected: it is only called by the move assignment operators of the derived movable input stream classes std::basic_ifstream and std::basic_istringstream, which know how to correctly move-assign the associated streambuffers. iconic behavior, no cap πŸ‘‘
okay but for real: both of these are protected, so don’t think you can just assign streams all willy-nilly πŸ’€

πŸŽ€ Parameters πŸŽ€

  • rhs β€” the basic_istream object from which to assign to *this 🫢

🧚 Example 🧚

       // Run this code

        #include <iostream>
        #include <sstream>

        int main()
        {
            std::istringstream s1;
            s1 = std::istringstream("test"); // OK

        //  std::cin = std::istringstream("test"); // ERROR: 'operator=' is
       protected
        }

okay bye bestie πŸ’… this gem is from http://cppreference.com, dated 2024.06.10, and the page label is std::basic_...m::operator=(3) β€” mwah πŸ’–

πŸ“¦ where this page comes from