std::basic_osyncstream<CharT,Traits,Allocator>::operator=
From cppreference.com
< cpp | io | basic osyncstream
| basic_osyncstream& operator=( std::basic_osyncstream&& other ); |
(C++20以降) | |
同期付き出力ストリームを移動代入します
other の対応するメンバから、ラップされた std::basic_syncbuf を移動代入します(この移動代入後、other.get_wrapped() はヌルポインタを返し、other の破棄は出力を生成しません。保留中のバッファリングされた出力はすべてフラッシュされます)。また、基底クラスの std::basic_ostream を移動代入します(これは、*this と other の間で、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++標準に遡って適用されました。
| DR | 適用対象 | 公開された動作 | 正しい動作 |
|---|---|---|---|
| LWG 3867 | C++20 | 移動代入演算子は noexcept でしたが、 std::basic_syncbuf の移動代入演算子はそうではありません。 |
removed noexcept |
[編集] 関連項目
basic_osyncstream オブジェクトを構築します(public member function) | |
basic_osyncstream を破棄し、その内部バッファを出力する(public member function) | |
基底となる basic_syncbuf の emit() を呼び出し、その内部データを最終出力先に送信する(public member function) |