C++ named requirements: FormattedInputFunction
Requirements
A FormattedInputFunction is a stream input function that performs the following:
- Constructs an object of type
basic_istream::sentrywith automatic storage duration and with thenoskipwsargument set tofalse, which performs the following - if
eofbitorbadbitare set on the input stream, sets thefailbitas well, and if exceptions on failbit are enabled in this input stream's exception mask, throwsios_base::failure. - flushes the tie()'d output stream, if applicable
- if
ios_base::skipwsflag is set on this input stream, extracts and discards characters from the input stream until one of the following becomes true: - the next available character on the input stream is not a whitespace character, as tested by the
std::ctypefacet of the locale currently imbued in this input stream. The non-whitespace character is not extracted. - the end of the stream is reached, in which case
failbitandeofbitare set and if the stream is on for exceptions on one of these bits,ios_base::failureis thrown. - Checks the status of the sentry by calling
sentry::operator bool(), which is equivalent tobasic_ios::good. - If the sentry returned
falseor sentry's constructor threw an exception, no input takes place - If the sentry returned
true, performs the input as if by callingrdbuf()->sbumpc()orrdbuf()->sgetc(). - if the end of the stream is reached (the call to
rdbuf()->sbumpc()orrdbuf()->sgetc()returnsTraits::eof()), setseofbit. If exceptions on eofbit are enabled in this stream's exception mask, throwsios_base::failure. - if an exception is thrown during input, sets
badbitin the input 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 FormattedInputFunctions.
-
basic_istream::operator>>(int, long, double, void*, bool) -
operator>>(std::basic_istream, char&) -
operator>>(std::basic_istream, char*) -
operator>>(std::basic_istream, std::bitset) -
operator>>(std::basic_istream, std::string) -
operator>>, when called on the return value ofstd::get_money
© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
http://en.cppreference.com/w/cpp/named_req/FormattedInputFunction