std::basic_osyncstream<CharT,Traits,Allocator>::operator=
来自 cppreference.cn
< cpp | io | basic osyncstream
basic_osyncstream& operator=( std::basic_osyncstream&& other ); |
(since C++20) | |
移动赋值同步输出流
从 other 的对应成员移动赋值包装的 std::basic_syncbuf(在此移动赋值后,other.get_wrapped() 返回空指针,且 other 的销毁不产生任何输出;任何待处理的缓冲输出都将被刷新),并 移动赋值 基类 std::basic_ostream(这会交换 *this 和 other 之间除 rdbuf
之外的所有流状态变量)
内容 |
[编辑] 参数
other | - | 要从中移动的另一个同步输出流 |
[编辑] 返回值
*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++ 标准。
DR | 应用于 | 已发布行为 | 正确行为 |
---|---|---|---|
LWG 3867 | C++20 | 移动赋值运算符是 noexcept,但是 std::basic_syncbuf 的移动赋值运算符不是 |
移除 noexcept |
[编辑] 参见
构造 basic_osyncstream 对象(public member function) | |
销毁 basic_osyncstream 并刷新其内部缓冲区(public member function) | |
在底层 basic_syncbuf 上调用 emit() 以将其内部数据传输到最终目标(public member function) |