首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

FormattedOutputFunction

Requirements

A FormattedOutputFunction is a stream output function that performs the following:

  • Constructs an object of type basic_ostream::sentry with automatic storage duration, which performs the following
    • if 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, throws ios_base::failure.
    • flushes the tie()'d output stream, if applicable.
  • Checks the status of the sentry by calling sentry::operator bool(), which is equivalent to basic_ios::good.
  • If the sentry returned false or sentry's constructor threw an exception, no output takes place
  • If the sentry returned true, attempts to perform the desired output by inserting the characters into the output stream as if by calling rdbuf()->sputc() or rdbuf()->xsputn(). Additionally, rdbuf()->overflow() and rdbuf()->sync() may be called, but no other virtual member function of std::basic_streambuf.
    • If the output could not be generated, sets failbit, If exceptions on failbit are enabled in this stream's exception mask, throws ios_base::failure.
    • if an exception is thrown during output, sets badbit in the output stream. If exceptions on badbit are enabled in this stream's exception mask, the exception is also rethrown.
    • If no exception was thrown, returns *this.
  • In any event, whether terminating by exception or returning, the sentry's destructor is called before leaving this function.

Standard library

The following standard library functions are FormattedOutputFunction**s**.

  • basic_ostream::operator<<(int, long, double, void*, bool)
  • operator<<(std::basic_ostream, char)
  • operator<<(std::basic_ostream, char*)
  • operator<<(std::basic_ostream, std::bitset)
  • operator<<(std::basic_ostream, std::string)
  • operator<< , when called on the return value of std::put_money
代码语言:txt
复制
 ? cppreference.com

Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com