Namespaces
Variants
Actions

std::basic_osyncstream<CharT,Traits,Allocator>::get_wrapped

From cppreference.com
 
C++
 
Input/output library
 
std::basic_osyncstream
Public member functions
basic_osyncstream::get_wrapped
(C++20)
 
streambuf_type* get_wrapped() const noexcept;

Returns a pointer to the wrapped std::basic_streambuf, obtained by calling get_wrapped() on the underlying std::basic_syncbuf.

[edit] Parameters

(none)

[edit] Example

Wrapped buffer can be safely wrapped again in a different synchronized output stream.

#include <iostream>
#include <syncstream>
 
int main()
{
    std::osyncstream bout1(std::cout);
    bout1 << "Hello, ";
    {
        std::osyncstream(bout1.get_wrapped() << "Goodbye, " << "Planet!" << '\n';
    } / emits the contents of the temporary buffer
    bout1 << "World!" << '\n';
} / emits the contents of bout1

Output:

Goodbye, Planet!
Hello, World!

[edit] See also

destroys the basic_osyncstream and emits its internal buffer
(public member function) [edit]
retrieves the wrapped streambuf pointer
(public member function of std::basic_syncbuf<CharT,Traits,Allocator>) [edit]

Follow Lee on X/Twitter - Father, Husband, Serial builder creating AI, crypto, games & web tools. We are friends :) AI Will Come To Life!

Check out: eBank.nz (Art Generator) | Netwrck.com (AI Tools) | Text-Generator.io (AI API) | BitBank.nz (Crypto AI) | ReadingTime (Kids Reading) | RewordGame | BigMultiplayerChess | WebFiddle | How.nz | Helix AI Assistant