The extraction of the numerical value follows the same rules as scanf with the appropriate format specifier, extracting characters from the sequence until the character extracted cannot be part of a valid numerical expression or end is reached. The next character in the sequence is pointed by the iterator returned by the function.
If the sequence of characters cannot produce a numerical value according to these rules and those specified by the numpunct facet of io's locale, the function sets err to ios_base::failbit.
If the function exhausts the sequence of characters (i.e., it reaches end) during its operations, ios_base::eofbit is set in err (both failbit and eofbit may be set by an operation).
Otherwise, ios_base::goodbit is set as err's value, indicating success.
During its operation, the version of this function in the generic template simply calls the virtual protected member do_get, which is the member function in charge of performing the actions described above.
- in, end
- Iterators pointing to the beginning and ending characters of the sequence. The range used is [in,end), which contains all the characters between in and end, including the character pointed by in but not the character pointed by end.
iter_type is a member alias of the second template parameter of num_get (i.e., the facet's iterator type). This can be any input iterator. By default, this is an istreambuf_iterator, allowing implicit conversions from istream objects.
- Object of a class derived from ios_base (generally an input stream object). It is only used to obtain formatting information.
- Stream error state object, of type ios_base::iostate where the resulting state will be stored.
- Object of a numerical type.
The function stores the value in it if it successfully extracted a number (i.e. if err's failbit flag is not set).
Return valueThe next character in the sequence right after where the extraction operation ended.
iter_type is a member alias of the second template parameter of num_get (i.e., the facet's iterator type).
Please, enter PI: 3.14 Right!
|num_put::put||Put numerical value (public member function)|
|istream::operator>>||Extract formatted data (public member function)|