A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://en.cppreference.com/w/cpp/thread/../io/basic_syncbuf/../basic_osyncstream/emit.html below:

std::basic_osyncstream<CharT,Traits,Allocator>::emit - cppreference.com

Emits all buffered output and executes any pending flushes, by calling emit() on the underlying std::basic_syncbuf.

[edit] Parameters

(none)

[edit] Example
#include <iostream>
#include <syncstream>
 
int main()
{
    {
        std::osyncstream bout(std::cout);
        bout << "Hello," << '\n'; // no flush
        bout.emit(); // characters transferred; cout not flushed
        bout << "World!" << std::endl; // flush noted; cout not flushed
        bout.emit(); // characters transferred; cout flushed
        bout << "Greetings." << '\n'; // no flush
    } // destructor calls emit(): characters transferred; cout not flushed
 
    // emit can be used for local exception-handling on the wrapped stream
    std::osyncstream bout(std::cout);
    bout << "Hello, " << "World!" << '\n';
    try
    {
        bout.emit();
    }
    catch (...)
    {
        // handle exceptions
    }
}

Output:

Hello,
World!
Greetings.
Hello, World!
[edit] See also destroys the basic_osyncstream and emits its internal buffer
(public member function) [edit] atomically transmits the entire internal buffer to the wrapped streambuf
(public member function of std::basic_syncbuf<CharT,Traits,Allocator>) [edit]

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4