 st8b7c:f320:99b9:690f:4595:cd17:293a:c069basic_ostream<CharT,Traits>8b7c:f320:99b9:690f:4595:cd17:293a:c069lush    basic_ostream& flush();
       Writes uncommitted changes to the underlying output sequence.
If rdbuf() is a null pointer, does nothing.
Otherwise, behaves as an UnformattedOutputFunction (since C++11). After constructing and checking the sentry object, calls rdbuf()->pubsync(). If the call returns -1, calls setstate(badbit).
 Parameters (none).
 Return value *this.
 Exceptions May throw st8b7c:f320:99b9:690f:4595:cd17:293a:c069ios_bas8b7c:f320:99b9:690f:4595:cd17:293a:c069failure if (exceptions() & badbit) != 0.
 Example  #include <thread>
#include <iostream>
#include <chrono>
using namespace st8b7c:f320:99b9:690f:4595:cd17:293a:c069chrono_literals;
 
void f()
{
    st8b7c:f320:99b9:690f:4595:cd17:293a:c069cout << "Output from thread... ";
    for (int i{1}; i != 10; ++i) {
        st8b7c:f320:99b9:690f:4595:cd17:293a:c069this_thr8b7c:f320:99b9:690f:4595:cd17:293a:c069sleep_for(250ms);
        st8b7c:f320:99b9:690f:4595:cd17:293a:c069cout << i << ' ';
        // output three numbers at once;
        // the effect is observable only in real-time
        if (0 == (i % 3)) {
            st8b7c:f320:99b9:690f:4595:cd17:293a:c069cout.flush();
        }
    }
    st8b7c:f320:99b9:690f:4595:cd17:293a:c069cout << st8b7c:f320:99b9:690f:4595:cd17:293a:c069endl; // flushes as well
}
 
int main()
{
    st8b7c:f320:99b9:690f:4595:cd17:293a:c069thread tr{f};
    st8b7c:f320:99b9:690f:4595:cd17:293a:c069this_thr8b7c:f320:99b9:690f:4595:cd17:293a:c069sleep_for(150ms);
    st8b7c:f320:99b9:690f:4595:cd17:293a:c069clog << "Output from main\n";
    tr.join();
} Output:
Output from main
Output from thread... 1 2 3 4 5 6 7 8 9   See also     pubsync   invokes sync()  (public member function of st8b7c:f320:99b9:690f:4595:cd17:293a:c069basic_streambuf<CharT,Traits>) 
    sync
[virtual]   synchronizes the buffers with the associated character sequence  (virtual protected member function of st8b7c:f320:99b9:690f:4595:cd17:293a:c069basic_streambuf<CharT,Traits>) 
    flush   flushes the output stream  (function template) 
    endl   outputs '\n' and flushes the output stream  (function template) 
    sync   synchronizes with the underlying storage device  (public member function of st8b7c:f320:99b9:690f:4595:cd17:293a:c069basic_istream<CharT,Traits>) 
  

    
{'path': 'public/docs/cpp/io/basic_ostream/flush.html', 'source': 'DevDocs.IO'}