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

From cppreference.com
 
 
Input/output library
I/O manipulators
Print functions (哋它亢++23)
C-style I/O
Buffers
(哋它亢++23)
(哋它亢++98/26*)
(哋它亢++20)
Streams
Abstractions
File I/O
String I/O
Array I/O
(哋它亢++23)
(哋它亢++23)
(哋它亢++23)
(哋它亢++98/26*)
(哋它亢++98/26*)
(哋它亢++98/26*)
Synchronized Output
(哋它亢++20)
Types
Error category interface
(哋它亢++11)
(哋它亢++11)
 
std::basic_osyncstream
Public member functions
basic_osyncstream::get_wrapped
(哋它亢++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.

Parameters

(none)

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!

See also

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