Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

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

      From cppreference.com
      <cpp‎ |io‎ |basic osyncstream
       
       
       
       
      void emit();

      Emits all buffered output and executes any pending flushes, by callingemit() on the underlyingstd::basic_syncbuf.

      [edit]Parameters

      (none)

      [edit]Example

      Run this code
      #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 streamstd::osyncstream bout(std::cout);    bout<<"Hello, "<<"World!"<<'\n';try{        bout.emit();}catch(...){// handle exceptions}}

      Output:

      Hello,World!Greetings.Hello, World!

      [edit]See also

      destroys thebasic_osyncstream and emits its internal buffer
      (public member function)[edit]
      atomically transmits the entire internal buffer to the wrapped streambuf
      (public member function ofstd::basic_syncbuf<CharT,Traits,Allocator>)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/io/basic_osyncstream/emit&oldid=158553"

      [8]ページ先頭

      ©2009-2025 Movatter.jp