名稱空間
變體
操作

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

來自 cppreference.com
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() 以將其內部資料傳輸到最終目標
(公開成員函式) [編輯]