31 Input/output library [input.output]

31.7 Formatting and manipulators [iostream.format]

31.7.5 Input streams [input.streams]

31.7.5.3 Formatted input functions [istream.formatted]

31.7.5.3.2 Arithmetic extractors [istream.formatted.arithmetic]

basic_istream& operator>>(unsigned short& val); basic_istream& operator>>(unsigned int& val); basic_istream& operator>>(long& val); basic_istream& operator>>(unsigned long& val); basic_istream& operator>>(long long& val); basic_istream& operator>>(unsigned long long& val); basic_istream& operator>>(float& val); basic_istream& operator>>(double& val); basic_istream& operator>>(long double& val); basic_istream& operator>>(bool& val); basic_istream& operator>>(void*& val);
As in the case of the inserters, these extractors depend on the locale's num_get<> object to perform parsing the input stream data.
These extractors behave as formatted input functions (as described in [istream.formatted.reqmts]).
After a sentry object is constructed, the conversion occurs as if performed by the following code fragment, where state represents the input function's local error state: using numget = num_get<charT, istreambuf_iterator<charT, traits>>; use_facet<numget>(loc).get(*this, 0, *this, state, val);
In the above fragment, loc stands for the private member of the basic_ios class.
[Note 1: 
The first argument provides an object of the istreambuf_iterator class which is an iterator pointed to an input stream.
It bypasses istreams and uses streambufs directly.
— end note]
Class locale relies on this type as its interface to istream, so that it does not need to depend directly on istream.
basic_istream& operator>>(short& val);
The conversion occurs as if performed by the following code fragment (using the same notation as for the preceding code fragment): using numget = num_get<charT, istreambuf_iterator<charT, traits>>; long lval; use_facet<numget>(loc).get(*this, 0, *this, state, lval); if (lval < numeric_limits<short>::min()) { state |= ios_base::failbit; val = numeric_limits<short>::min(); } else if (numeric_limits<short>::max() < lval) { state |= ios_base::failbit; val = numeric_limits<short>::max(); } else val = static_cast<short>(lval);
basic_istream& operator>>(int& val);
The conversion occurs as if performed by the following code fragment (using the same notation as for the preceding code fragment): using numget = num_get<charT, istreambuf_iterator<charT, traits>>; long lval; use_facet<numget>(loc).get(*this, 0, *this, state, lval); if (lval < numeric_limits<int>::min()) { state |= ios_base::failbit; val = numeric_limits<int>::min(); } else if (numeric_limits<int>::max() < lval) { state |= ios_base::failbit; val = numeric_limits<int>::max(); } else val = static_cast<int>(lval);
basic_istream& operator>>(extended-floating-point-type& val);
If the floating-point conversion rank of extended-floating-point-type is not less than or equal to that of long double, then an invocation of the operator function is conditionally supported with implementation-defined semantics.
Otherwise, let FP be a standard floating-point type:
  • if the floating-point conversion rank of extended-floating-point-type is less than or equal to that of float, then FP is float,
  • otherwise, if the floating-point conversion rank of extended-floating-point-type is less than or equal to that of double, then FP is double,
  • otherwise, FP is long double.
The conversion occurs as if performed by the following code fragment (using the same notation as for the preceding code fragment): using numget = num_get<charT, istreambuf_iterator<charT, traits>>; FP fval; use_facet<numget>(loc).get(*this, 0, *this, state, fval); if (fval < -numeric_limits<extended-floating-point-type>::max()) { state |= ios_base::failbit; val = -numeric_limits<extended-floating-point-type>::max(); } else if (numeric_limits<extended-floating-point-type>::max() < fval) { state |= ios_base::failbit; val = numeric_limits<extended-floating-point-type>::max(); } else { val = static_cast<extended-floating-point-type>(fval); }
[Note 2: 
When the extended floating-point type has a floating-point conversion rank that is not equal to the rank of any standard floating-point type, then double rounding during the conversion can result in inaccurate results.
from_chars can be used in situations where maximum accuracy is important.
— end note]