Namespaces
Variants

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

From cppreference.net
void emit ( ) ;

Emite toda la salida almacenada en el búfer y ejecuta cualquier vaciado pendiente, llamando a emit() en el std::basic_syncbuf subyacente.

Parámetros

(ninguno)

Ejemplo

#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
    }
}

Salida:

Hello,
World!
Greetings.
Hello, World!

Véase también

destruye el basic_osyncstream y emite su buffer interno
(función miembro pública)
transmite atómicamente todo el buffer interno al streambuf envuelto
(función miembro pública de std::basic_syncbuf<CharT,Traits,Allocator> )