A FormattedOutputFunction is a stream output function that performs the following:
basic_ostream::sentry
with automatic storage duration, which performs the following eofbit
or badbit
are set on the output stream, sets the failbit
as well, and if exceptions on failbit
are enabled in this output stream's exception mask ((exceptions() & failbit) != 0
), throws ios_base::failure
. sentry::operator bool()
, which is equivalent to basic_ios::good
. false
or sentry's constructor threw an exception, no output takes place true
, attempts to perform the desired output by inserting the characters into the output stream as if by calling rdbuf()->sputc()
. Other public members of std::basic_ostream
may also be used, but virtual members of rdbuf()
except overflow()
, xsputn()
and sync()
will never be called. failbit
. If exceptions on failbit
are enabled in this stream's exception mask ((exceptions() & failbit) != 0
), throws ios_base::failure
. badbit
in the output stream. If exceptions on badbit
are enabled in this stream's exception mask ((exceptions() & badbit) != 0
), the exception is also rethrown. *this
. Formatted output functions determine padding according to | (until C++14) |
If a formatted output function of a stream Given a If | (since C++14) |
The following standard library functions are FormattedOutputFunctions.
basic_ostream::operator<<(std::basic_ostream&, int / long / double / void* / bool)
operator<<(std::basic_ostream&, char)
operator<<(std::basic_ostream&, char*)
operator<<(std::basic_ostream&, const std::bitset&)
operator<<(std::basic_ostream&, const std::basic_string&)
operator<<
, when called on the return value of std::put_money
(since C++17) |
os is an output stream object):
| (since C++23) |
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
DR | Applied to | Behavior as published | Correct behavior |
---|---|---|---|
LWG 160 | C++98 | the process of determining whether the exception caught is rethrown mentioned a non-existing function exception() | corrected to exceptions() |
LWG 165 | C++98 | the only virtual member allowed to be called on rdbuf() was overflow() | also allowedxsputn() and sync() |
© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
https://en.cppreference.com/w/cpp/named_req/FormattedOutputFunction