std::basic_ostream<CharT,Traits>::operator= (3) - Linux Manuals
std::basic_ostream<CharT,Traits>::operator=: std::basic_ostream<CharT,Traits>::operator=
Command to display std::basic_ostream<CharT,Traits>::operator=
manual in Linux: $ man 3 std::basic_ostream<CharT,Traits>::operator=
NAME
std::basic_ostream<CharT,Traits>::operator= - std::basic_ostream<CharT,Traits>::operator=
Synopsis
protected: (1)
basic_ostream& operator=( const basic_ostream& rhs ) = delete;
protected: (2) (since C++11)
basic_ostream& operator=( basic_ostream&& rhs );
1) The copy assignment operator is protected, and is deleted. Output streams are not CopyAssignable.
2) The move assignment operator exchanges 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 output stream classes std::basic_ofstream and std::basic_ostringstream, which know how to correctly move-assign the associated streambuffers.
Parameters
rhs - the basic_ostream object from which to assign to *this
Example
// Run this code
#include <sstream>
#include <utility>
#include <iostream>
int main()
{
std::ostringstream s;
// std::cout = s; // ERROR: copy assignment operator is deleted
// std::cout = std::move(s); // ERROR: move assignment operator is protected
s = std::move(std::ostringstream() << 42); // OK, moved through derived
std::cout << s.str() << '\n';
}
Output:
42
Pages related to std::basic_ostream<CharT,Traits>::operator=
- std::basic_ostream<CharT,Traits>::operator<< (3) - std::basic_ostream<CharT,Traits>::operator<<
- std::basic_ostream<CharT,Traits>::basic_ostream (3) - std::basic_ostream<CharT,Traits>::basic_ostream
- std::basic_ostream<CharT,Traits>::flush (3) - std::basic_ostream<CharT,Traits>::flush
- std::basic_ostream<CharT,Traits>::put (3) - std::basic_ostream<CharT,Traits>::put
- std::basic_ostream<CharT,Traits>::seekp (3) - std::basic_ostream<CharT,Traits>::seekp
- std::basic_ostream<CharT,Traits>::sentry (3) - std::basic_ostream<CharT,Traits>::sentry
- std::basic_ostream<CharT,Traits>::swap (3) - std::basic_ostream<CharT,Traits>::swap
- std::basic_ostream<CharT,Traits>::tellp (3) - std::basic_ostream<CharT,Traits>::tellp
- std::basic_ostream<CharT,Traits>::write (3) - std::basic_ostream<CharT,Traits>::write
- std::basic_ostream<CharT,Traits>::~basic_ostream (3) - std::basic_ostream<CharT,Traits>::~basic_ostream
- std::basic_ostream (3) - std::basic_ostream
- std::basic_ostream_sentry (3)
- std::basic_ostringstream (3) - std::basic_ostringstream
- std::basic_ostringstream::operator= (3) - std::basic_ostringstream::operator=
- std::basic_ostringstream::rdbuf (3) - std::basic_ostringstream::rdbuf
- std::basic_ostringstream::swap (3) - std::basic_ostringstream::swap
- std::basic_ostringstream<CharT,Traits,Allocator>::basic_ostringstream (3) - std::basic_ostringstream<CharT,Traits,Allocator>::basic_ostringstream
- std::basic_ostringstream<CharT,Traits,Allocator>::str (3) - std::basic_ostringstream<CharT,Traits,Allocator>::str
- std::basic_osyncstream (3) - std::basic_osyncstream