std::basic_...tream::emit(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

✨ NAME ✨

std::basic_osyncstream::emit β€” okay so the NAME is literally std::basic_osyncstream::emit, and the page is also std::basic_osyncstream::emit. We love a name section that ate and left no crumbs πŸ’…

This is the C++ Standard Libary manual, page std::basic_...tream::emit(3) β€” yes bestie, that spelling is staying, no cap.


πŸ“œ Synopsis

void emit();

It emits all buffered output and executes any pending flushes, by calling emit() on the underlying std::basic_syncbuf. That's the whole vibe: flush-adjacent behavior, but routed through the syncbuf. Periodt πŸ’–


πŸŽ›οΈ Parameters

Parameters: (none) β€” literally no parameters, bestie. Zero. Zilch. The function signature said β€œI’m enough” and honestly? She is 🫢


πŸ’» 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
       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)
  • emit β€” atomically transmits the entire internal buffer to the wrapped streambuf (public member function of std::basic_syncbuf<CharT,Traits,Allocator>)

πŸ’– source/version/date sign-off: http://cppreference.com Β· 2024.06.10 Β· std::basic_...tream::emit(3) β€” byeee, slay responsibly 🫢✨

πŸ“¦ where this page comes from