std::basic_ostream::operator=

来自cppreference.com
< cpp‎ | io‎ | basic ostream

 
 
 
std::basic_ostream
全局对象
原文:
Global objects
文本通过谷歌翻译机器翻译。
你可以帮忙校正和验证翻译。点击此处查看指示。
成员函数
原文:
Member functions
文本通过谷歌翻译机器翻译。
你可以帮忙校正和验证翻译。点击此处查看指示。
basic_ostream::operator=
(C++11)
格式化的输入
原文:
Formatted input
文本通过谷歌翻译机器翻译。
你可以帮忙校正和验证翻译。点击此处查看指示。
未格式化的输入
原文:
Unformatted input
文本通过谷歌翻译机器翻译。
你可以帮忙校正和验证翻译。点击此处查看指示。
定位
原文:
Positioning
文本通过谷歌翻译机器翻译。
你可以帮忙校正和验证翻译。点击此处查看指示。
杂项
原文:
Miscellaneous
文本通过谷歌翻译机器翻译。
你可以帮忙校正和验证翻译。点击此处查看指示。
会员类别
原文:
Member classes
文本通过谷歌翻译机器翻译。
你可以帮忙校正和验证翻译。点击此处查看指示。
非成员函数
原文:
Non-member functions
文本通过谷歌翻译机器翻译。
你可以帮忙校正和验证翻译。点击此处查看指示。
 
protected:
basic_istream& operator=( const basic_ostream& rhs ) = delete;
(1)
protected:
basic_ostream& operator=( basic_ostream&& rhs );
(2) (C++11 起)

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

[编辑] 示例

#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