GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
std::basic_ostream::operator=(3) C++ Standard Libary std::basic_ostream::operator=(3)

std::basic_ostream::operator= - std::basic_ostream::operator=


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.


rhs - the basic_ostream object from which to assign to *this

// 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';
}


42

2022.07.31 http://cppreference.com

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.