Spec-Zone.ru › C++

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

void emit();

Выводит все буферизованные данные и выполняет все запланированные флеши, вызывая emit() в базовом std::basic_syncbuf.

Параметры

(нет)

Пример

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

Вывод:

Hello,
World!
Greetings.
Hello, World!

См. также

(деструктор)
уничтожает basic_osyncstream и выводит свой внутренний буфер
(публичный член-функция)
emit
атомарно передаёт весь внутренний буфер в обёрнутый streambuf
(публичный член-функция std::basic_syncbuf<CharT,Traits,Allocator>)

© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
https://en.cppreference.com/w/cpp/io/basic_osyncstream/emit

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API