Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
std::basic_...tream::emit(3)  C++ Standard Libary std::basic_...tream::emit(3)

NAME
       std::basic_osyncstream::emit - std::basic_osyncstream::emit

Synopsis
	  void emit();

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

Parameters
	  (none)

Example
       // Run this code

	#include <syncstream>
	#include <iostream>
	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!

See also
	  destructor	destroys  the basic_osyncstream	and emits its internal
       buffer
		       (public member function)
		       atomically transmits the	entire internal	buffer to  the
       wrapped
	  emit	       streambuf
		       (public	    member	function      of      std::ba-
       sic_syncbuf<CharT,Traits,Allocator>)

http://cppreference.com		  2022.07.31	  std::basic_...tream::emit(3)

Want to link to this manual page? Use this URL:
<https://man.freebsd.org/cgi/man.cgi?query=std::basic_osyncstream::emit&sektion=3&manpath=FreeBSD+Ports+15.0>

home | help