A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://en.cppreference.com/w/cpp/algorithm/../algorithm/../locale/num_get/get.html below:

std::num_get<CharT,InputIt>::get, std::num_get<CharT,InputIt>::do_get - cppreference.com

(1) (since C++11) (since C++11) (2) (since C++11) (since C++11)

1) Public member function, calls the member function do_get of the most derived class.

2)

Reads characters from the input iterator

in

and generates the value of the type of

v

, taking into account I/O stream formatting flags from

str.flags()

, character classification rules from

std::use_facet<std::ctype<CharT>>(str.getloc())

, and numeric punctuation characters from

std::use_facet<std::numpunct<CharT>>(str.getloc())

. This function is called by all formatted input stream operators such as

std::cin >> n;

.

Conversion occurs in three stages:

[edit] Stage 1: conversion specifier selection
fmtflags basefield = (str.flags() & std::ios_base::basefield);
fmtflags boolalpha = (str.flags() & std::ios_base::boolalpha);
If basefield == oct, will use conversion specifier %o
If basefield == hex, will use conversion specifier %X
If basefield == 0, will use conversion specifier %i
If the type of v is signed, will use conversion specifier %d
If the type of v is unsigned, will use conversion specifier %u
[edit] [edit] Stage 3: conversion and storage [edit] Return value

in

[edit] Notes

Before the resolutions of LWG issue 23 and LWG issue 696, v was left unchanged if an error occurs.

Before the resolution of LWG issue 221, strings representing hexadecimal integers (e.g. "0xA0") were rejected by do_get(int) even if they are valid input to strtol because stage 2 filters out characters 'X' and 'x'.

Before the resolution of LWG issue 1169, converting a negative number string into an unsigned integer might produce zero (since the value represented by the string is smaller than what the target type can represent).

Before the resolution of LWG issue 2381, strings representing hexadecimal floating-point numbers with exponents (e.g. "0x1.23p-10") were rejected by do_get(double) even if they are valid input to strtod because stage 2 filters out characters 'P' and 'p'.

The strings representing infinity or not-a-number (e.g. "NaN" and "inf") are rejected by do_get(double) even if they are valid input to strtod because stage 2 filters out characters such as 'N' or 'i'.

(since C++11) [edit] Example

An implementation of operator>> for a user-defined type.

[edit] Defect reports

The following behavior-changing defect reports were applied retroactively to previously published C++ standards.

DR Applied to Behavior as published Correct behavior LWG 17 C++98 the process of parsing text boolean values was errornous corrected LWG 18 C++98 the overload of get taking bool& value was missing added LWG 23 C++98 overflowing input resulted in undefined behavior overflow handled LWG 154 C++98 the conversion specifier for double was %g (same as float) changed to %lg LWG 221 C++98 do_get did not parse 'x' and 'X' while strtol parsed them made 'x' and 'X' parsed LWG 275 C++98 get had an overload taking short& value instead of float& corrected LWG 358 C++98 thousand separators after the decimal point were ignored stage 2 is terminated if encountered LWG 696 C++98 the result was unchanged on conversion failure set to zero LWG 1169 C++98 overflow handling was inconsistent between floating-point types made consistent
with strtof/strtod LWG 2381 C++11 do_get did not parse 'p' and 'P' while strtod parsed them made 'p' and 'P' parsed [edit] See also extracts formatted data
(public member function of std::basic_istream<CharT,Traits>) [edit]

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4