std::basic_osyncstream<CharT,Traits,Allocator>::operator=
從 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
之外的所有流狀態變量)。
目錄 |
[編輯] 參數
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); // 注意 out 于此处发出 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() 以傳輸它的內部數據到最終目標 (公開成員函數) |