命名空间
变体
操作

std::basic_osyncstream<CharT,Traits,Allocator>::operator=

来自 cppreference.cn
basic_osyncstream& operator=( std::basic_osyncstream&& other );
(C++20 起)

移动赋值一个同步输出流。

other 的对应成员移动赋值被包装的 std::basic_syncbuf(此移动赋值后,other.get_wrapped() 返回空指针且 other 的销毁不产生输出;任何待决的缓冲输出都会被发出),并移动赋值基类 std::basic_ostream(这会交换 *thisother 之间除 rdbuf 外的所有流状态变量)。

目录

[编辑] 参数

其他 - 另一个要从中移动的同步输出流。

[编辑] 返回值

*this

[编辑] 示例

#include <iomanip>
#include <iostream>
#include <sstream>
#include <syncstream>
#include <utility>
 
int main()
{
    std::osyncstream out(std::cout);
    out << "test\n";
    std::ostringstream str_out;
    std::osyncstream{str_out} = std::move(out); // Note that out is emitted here
    std::cout << "str_out = " << std::quoted(str_out.view()) << '\n';
}

输出

test
str_out = ""

[编辑] 缺陷报告

下列更改行为的缺陷报告追溯地应用于以前出版的 C++ 标准。

缺陷报告 应用于 发布时的行为 正确的行为
LWG 3867 C++20 移动赋值运算符曾是 noexcept,但
std::basic_syncbuf 的移动赋值运算符不是
移除了 noexcept

[编辑] 参阅

构造 basic_osyncstream 对象
(公开成员函数) [编辑]
销毁 basic_osyncstream 并发出其内部缓冲区
(公开成员函数) [编辑]
调用底层 basic_syncbuf 上的 emit() 以将其内部数据传输到最终目标
(公开成员函数) [编辑]