std::basic_ostream<CharT,Traits>::operator=

  1. The copy assignment operator is protected, and is deleted. Output streams are not CopyAssignable.

# Declarations

protected:
basic_ostream& operator=( const basic_ostream& rhs ) = delete;
protected:
basic_ostream& operator=( basic_ostream&& rhs );

(since C++11)

# Parameters

# Example

#include <iostream>
#include <sstream>
#include <utility>
 
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';
}

# Defect reports

DRApplied toBehavior as publishedCorrect behavior
LWG 2067C++111. the parameter type of overload (1) was basic_ostream&2. the parameter type of overload (2) was const basic_ostream&&1. added const2. removed const