Namespaces
Variants

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

From cppreference.net
void emit ( ) ;

버퍼링된 모든 출력을 방출하고 보류 중인 플러시를 실행합니다. 이는 기본 emit() 함수를 std::basic_syncbuf 객체에서 호출함으로써 수행됩니다.

매개변수

(없음)

예제

#include <iostream>
#include <syncstream>
int main()
{
    {
        std::osyncstream bout(std::cout);
        bout << "Hello," << '\n'; // 플러시 없음
        bout.emit(); // 문자 전송됨; cout은 플러시되지 않음
        bout << "World!" << std::endl; // 플러시 표시됨; cout은 플러시되지 않음
        bout.emit(); // 문자 전송됨; cout이 플러시됨
        bout << "Greetings." << '\n'; // 플러시 없음
    } // 소멸자가 emit() 호출: 문자 전송됨; cout은 플러시되지 않음
    // emit은 래핑된 스트림에 대한 지역적 예외 처리를 위해 사용될 수 있음
    std::osyncstream bout(std::cout);
    bout << "Hello, " << "World!" << '\n';
    try
    {
        bout.emit();
    }
    catch (...)
    {
        // 예외 처리
    }
}

출력:

Hello,
World!
Greetings.
Hello, World!

참고 항목

basic_osyncstream 를 파괴하고 내부 버퍼를 방출함
(public member function)
전체 내부 버퍼를 래핑된 streambuf로 원자적으로 전송함
( std::basic_syncbuf<CharT,Traits,Allocator> 의 public member function)