std::basic_ostream<CharT,Traits>::flush (3) - Linux Manuals
std::basic_ostream<CharT,Traits>::flush: std::basic_ostream<CharT,Traits>::flush
Command to display std::basic_ostream<CharT,Traits>::flush
manual in Linux: $ man 3 std::basic_ostream<CharT,Traits>::flush
NAME
std::basic_ostream<CharT,Traits>::flush - std::basic_ostream<CharT,Traits>::flush
Synopsis
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 std::ios_base::failure if exceptions()&badbit!=0.
Example
// Run this code
#include <thread>
#include <iostream>
#include <chrono>
void f()
{
std::cout << "Output from thread...";
std::this_thread::sleep_for(std::chrono::seconds(2));
std::cout << "...thread calls flush()\n";
std::cout.flush();
}
int main()
{
std::thread t1(f);
std::this_thread::sleep_for(std::chrono::seconds(1));
std::clog << "Output from main\n";
t1.join();
}
Output:
Output from main
Output from thread.....thread calls flush()
See also
synchronizes with the underlying storage device
sync (public member function of std::basic_istream<CharT,Traits>)
flushes the output stream
flush (function template)
outputs '\n' and flushes the output stream
endl (function template)
Pages related to std::basic_ostream<CharT,Traits>::flush
- std::basic_ostream<CharT,Traits>::basic_ostream (3) - std::basic_ostream<CharT,Traits>::basic_ostream
- std::basic_ostream<CharT,Traits>::operator<< (3) - std::basic_ostream<CharT,Traits>::operator<<
- std::basic_ostream<CharT,Traits>::operator= (3) - std::basic_ostream<CharT,Traits>::operator=
- std::basic_ostream<CharT,Traits>::put (3) - std::basic_ostream<CharT,Traits>::put
- std::basic_ostream<CharT,Traits>::seekp (3) - std::basic_ostream<CharT,Traits>::seekp
- std::basic_ostream<CharT,Traits>::sentry (3) - std::basic_ostream<CharT,Traits>::sentry
- std::basic_ostream<CharT,Traits>::swap (3) - std::basic_ostream<CharT,Traits>::swap
- std::basic_ostream<CharT,Traits>::tellp (3) - std::basic_ostream<CharT,Traits>::tellp
- std::basic_ostream<CharT,Traits>::write (3) - std::basic_ostream<CharT,Traits>::write
- std::basic_ostream<CharT,Traits>::~basic_ostream (3) - std::basic_ostream<CharT,Traits>::~basic_ostream
- std::basic_ostream (3) - std::basic_ostream
- std::basic_ostream_sentry (3)
- std::basic_ostringstream (3) - std::basic_ostringstream
- std::basic_ostringstream::operator= (3) - std::basic_ostringstream::operator=
- std::basic_ostringstream::rdbuf (3) - std::basic_ostringstream::rdbuf
- std::basic_ostringstream::swap (3) - std::basic_ostringstream::swap
- std::basic_ostringstream<CharT,Traits,Allocator>::basic_ostringstream (3) - std::basic_ostringstream<CharT,Traits,Allocator>::basic_ostringstream
- std::basic_ostringstream<CharT,Traits,Allocator>::str (3) - std::basic_ostringstream<CharT,Traits,Allocator>::str
- std::basic_osyncstream (3) - std::basic_osyncstream