std::basic_...m::operator=(3)
π¦ std::basic_osyncstream::operator= π¦
okay so this is the std::basic_...m::operator=(3) page from the C++ Standard Libary manual (section 3) β yes, the header spells it βLibary,β and we are not fixing it, periodt. The full-name main character is std::basic_osyncstream::operator=, and she is literally the move-assignment operator for a synchronized output stream. π
π NAME π
std::basic_osyncstream::operator= β std::basic_osyncstream::operator= (yes, the original NAME line is literally the same string twice, and weβre keeping that exact mirror-selfie energy). πͺβ¨
πΈ Synopsis πΈ
basic_osyncstream& operator=( std::basic_osyncstream&& other );
Since C++20 β this oneβs been around since C++20, bestie. π
Move-assigns a synchronized output stream: π«
- It move-assigns the wrapped
std::basic_syncbuffrom the corresponding member ofother. After this move-assignment,other.get_wrapped()returns a null pointer, and destruction ofotherproduces no output; any pending buffered output will be emitted. π«Ά - It also move-assigns the base
std::basic_ostreamβ this swaps all stream state variables exceptrdbufbetween*thisandother. π
π Parameters π
otherβ another synchronized output stream to move from. π
π Return value π
*this β thatβs the return, periodt. π
π₯ Example π₯
// Run this code β hit it, bestie:
#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';
}
β Output β
test
str_out = ""
π§ Defect reports π§
The following behavior-changing defect reports were applied retroactively to previously published C++ standards. π
LWG 3867β applied to C++20. Behavior as published: the move assignment operator wasnoexcept, butstd::basic_syncbuf's move assignment operator is not. Correct behavior: removednoexcept. π«
π See also π
- constructor β constructs a
basic_osyncstreamobject (public member function). π - destructor β destroys the
basic_osyncstreamand emits its internal buffer (public member function). π«Ά - emit β calls
emit()on the underlyingbasic_syncbufto transmit its internal data to the final destination (public member function). β¨
okay bestie, thatβs the tea: this page came from source http://cppreference.com, version/date 2024.06.10, and the footer title is std::basic_...m::operator=(3). byeee, go move-assign something safely ππ¦β¨
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms