STD::NUM_GET(3)
π std::num_get< _CharT, _InIter > π
okay so bestie, we're in the Library Functions Manual, section 3 (that's the C++ library section, iykyk), and today's main character is std::num_get< _CharT, _InIter >. pull up a chair, grab a strawberry π, this one's a whole vibe.
π NAME π
std::num_get< _CharT, _InIter > β the Primary class template num_get.
β¨ SYNOPSIS β¨
#include <locale>
Also, just so we're clear: it inherits std::locale::facet. π
πΈ Public Types
These are the Public typedefs, two of them, both iconic:
typedef _CharT char_typeβ Public typedefs.typedef _InIter iter_typeβ Public typedefs.
π Public Member Functions
num_get (size_t __refs=0)β Constructor performs initialization.template<typename _ValueT> _InIter _M_extract_int (_InIter __beg, _InIter __end, ios_base &__io, ios_base::iostate &__err, _ValueT &__v) constiter_type get (iter_type __in, iter_type __end, ios_base &__io, ios_base::iostate &__err, bool &__v) constβ Numeric parsing.iter_type get (iter_type __in, iter_type __end, ios_base &__io, ios_base::iostate &__err, void *&__v) constβ Numeric parsing.iter_type get (iter_type __in, iter_type __end, ios_base &__io, ios_base::iostate &__err, long &__v) constβ Numeric parsing.iter_type get (iter_type __in, iter_type __end, ios_base &__io, ios_base::iostate &__err, unsigned short &__v) constβ Numeric parsing.iter_type get (iter_type __in, iter_type __end, ios_base &__io, ios_base::iostate &__err, unsigned int &__v) constβ Numeric parsing.iter_type get (iter_type __in, iter_type __end, ios_base &__io, ios_base::iostate &__err, unsigned long &__v) constβ Numeric parsing.iter_type get (iter_type __in, iter_type __end, ios_base &__io, ios_base::iostate &__err, long long &__v) constβ Numeric parsing.iter_type get (iter_type __in, iter_type __end, ios_base &__io, ios_base::iostate &__err, unsigned long long &__v) constβ Numeric parsing.iter_type get (iter_type __in, iter_type __end, ios_base &__io, ios_base::iostate &__err, float &__v) constβ Numeric parsing.iter_type get (iter_type __in, iter_type __end, ios_base &__io, ios_base::iostate &__err, double &__v) constβ Numeric parsing.iter_type get (iter_type __in, iter_type __end, ios_base &__io, ios_base::iostate &__err, long double &__v) constβ Numeric parsing.
π Static Public Attributes
static locale::id idβ Numpunct facet id.
π¦ Protected Member Functions
virtual ~num_get ()β Destructor.iter_type _M_extract_float (iter_type, iter_type, ios_base &, ios_base::iostate &, string &) consttemplate<typename _ValueT> iter_type _M_extract_int (iter_type, iter_type, ios_base &, ios_base::iostate &, _ValueT &) consttemplate<typename _CharT2> __gnu_cxx::__enable_if< __is_char< _CharT2 >::__value, int >::__type _M_find (const _CharT2 *, size_t __len, _CharT2 __c) consttemplate<typename _CharT2> __gnu_cxx::__enable_if<!__is_char< _CharT2 >::__value, int >::__type _M_find (const _CharT2 *__zero, size_t __len, _CharT2 __c) constvirtual iter_type do_get (iter_type, iter_type, ios_base &, ios_base::iostate &, bool &) constβ Numeric parsing.virtual iter_type do_get (iter_type __beg, iter_type __end, ios_base &__io, ios_base::iostate &__err, long &__v) constβ Numeric parsing.virtual iter_type do_get (iter_type __beg, iter_type __end, ios_base &__io, ios_base::iostate &__err, unsigned short &__v) constβ Numeric parsing.virtual iter_type do_get (iter_type __beg, iter_type __end, ios_base &__io, ios_base::iostate &__err, unsigned int &__v) constβ Numeric parsing.virtual iter_type do_get (iter_type __beg, iter_type __end, ios_base &__io, ios_base::iostate &__err, unsigned long &__v) constβ Numeric parsing.virtual iter_type do_get (iter_type __beg, iter_type __end, ios_base &__io, ios_base::iostate &__err, long long &__v) constβ Numeric parsing.virtual iter_type do_get (iter_type __beg, iter_type __end, ios_base &__io, ios_base::iostate &__err, unsigned long long &__v) constβ Numeric parsing.virtual iter_type do_get (iter_type, iter_type, ios_base &, ios_base::iostate &, float &) constβ Numeric parsing.virtual iter_type do_get (iter_type, iter_type, ios_base &, ios_base::iostate &, double &) constβ Numeric parsing.virtual iter_type do_get (iter_type, iter_type, ios_base &, ios_base::iostate &, long double &) constβ Numeric parsing.virtual iter_type do_get (iter_type, iter_type, ios_base &, ios_base::iostate &, void *&) constβ Numeric parsing.
π§ Static Protected Member Functions
static __c_locale _S_clone_c_locale (__c_locale &__cloc) throw ()static void _S_create_c_locale (__c_locale &__cloc, const char *__s, __c_locale __old=0)static void _S_destroy_c_locale (__c_locale &__cloc)static __c_locale _S_get_c_locale ()static const char * _S_get_c_name () throw ()static __c_locale _S_lc_ctype_c_locale (__c_locale __cloc, const char *__s)
π DETAILED DESCRIPTION π
template<typename _CharT, typename _InIter>
class std::num_get< _CharT, _InIter >
Primary class template num_get.
So like, what is this thing? This facet encapsulates the code to parse and return a number from a string. That's the whole job. It's the little engine that runs when you do the istream numeric extraction operators β you know, when you casually do cin >> my_number and it just... works. that's her. she did that. π
And here's the tea: the num_get template uses protected virtual functions to actually produce the results. The public accessors don't do the work themselves β they just forward the call to the virtual functions. And those virtual functions are hooks for developers to implement the behavior they require from the num_get facet. so if you wanna customize the whole numeric-parsing situation, the hooks are right there waiting for you. no cap. π«Ά
π MEMBER TYPEDEF DOCUMENTATION π
template<typename _CharT, typename _InIter> typedef _CharT std::num_get< _CharT, _InIter >::char_type
Public typedefs.
template<typename _CharT, typename _InIter> typedef _InIter std::num_get< _CharT, _InIter >::iter_type
Public typedefs.
β¨ CONSTRUCTOR & DESTRUCTOR DOCUMENTATION β¨
template<typename _CharT, typename _InIter> std::num_get< _CharT, _InIter >::num_get (size_t __refs = 0) [inline], [explicit]
Constructor performs initialization. This is the constructor provided by the standard.
Parameters
__refsβ Passed to the base facet class.
template<typename _CharT, typename _InIter> virtual std::num_get< _CharT, _InIter >::~num_get () [inline], [protected], [virtual]
Destructor. that's it, that's the whole note. she's protected, she's virtual, she's inline. leave her be. π
π MEMBER FUNCTION DOCUMENTATION π
heads up bestie, all of these do_get overloads share the exact same little description block, so I'm giving you the full tea on each one, no skimping. π«Ά
template<typename _CharT, typename _InIter> virtual iter_type std::num_get< _CharT, _InIter >::do_get (iter_type __beg, iter_type __end, ios_base & __io, ios_base::iostate & __err, long & __v) const [inline], [protected], [virtual]
Numeric parsing. Parses the input stream into the variable v. This function is a hook for derived classes to change the value returned.
See also
get() for more details.
Parameters
__begβ Start of input stream.__endβ End of input stream.__ioβ Source of locale and flags.__errβ Error flags to set.__vβ Value to format and insert.
Returns
Iterator after reading.
template<typename _CharT, typename _InIter> virtual iter_type std::num_get< _CharT, _InIter >::do_get (iter_type __beg, iter_type __end, ios_base & __io, ios_base::iostate & __err, long long & __v) const [inline], [protected], [virtual]
Numeric parsing. Parses the input stream into the variable v. This function is a hook for derived classes to change the value returned.
See also
get() for more details.
Parameters
__begβ Start of input stream.__endβ End of input stream.__ioβ Source of locale and flags.__errβ Error flags to set.__vβ Value to format and insert.
Returns
Iterator after reading.
template<typename _CharT, typename _InIter> virtual iter_type std::num_get< _CharT, _InIter >::do_get (iter_type __beg, iter_type __end, ios_base & __io, ios_base::iostate & __err, unsigned int & __v) const [inline], [protected], [virtual]
Numeric parsing. Parses the input stream into the variable v. This function is a hook for derived classes to change the value returned.
See also
get() for more details.
Parameters
__begβ Start of input stream.__endβ End of input stream.__ioβ Source of locale and flags.__errβ Error flags to set.__vβ Value to format and insert.
Returns
Iterator after reading.
template<typename _CharT, typename _InIter> virtual iter_type std::num_get< _CharT, _InIter >::do_get (iter_type __beg, iter_type __end, ios_base & __io, ios_base::iostate & __err, unsigned long & __v) const [inline], [protected], [virtual]
Numeric parsing. Parses the input stream into the variable v. This function is a hook for derived classes to change the value returned.
See also
get() for more details.
Parameters
__begβ Start of input stream.__endβ End of input stream.__ioβ Source of locale and flags.__errβ Error flags to set.__vβ Value to format and insert.
Returns
Iterator after reading.
template<typename _CharT, typename _InIter> virtual iter_type std::num_get< _CharT, _InIter >::do_get (iter_type __beg, iter_type __end, ios_base & __io, ios_base::iostate & __err, unsigned long long & __v) const [inline], [protected], [virtual]
Numeric parsing. Parses the input stream into the variable v. This function is a hook for derived classes to change the value returned.
See also
get() for more details.
Parameters
__begβ Start of input stream.__endβ End of input stream.__ioβ Source of locale and flags.__errβ Error flags to set.__vβ Value to format and insert.
Returns
Iterator after reading.
template<typename _CharT, typename _InIter> virtual iter_type std::num_get< _CharT, _InIter >::do_get (iter_type __beg, iter_type __end, ios_base & __io, ios_base::iostate & __err, unsigned short & __v) const [inline], [protected], [virtual]
Numeric parsing. Parses the input stream into the variable v. This function is a hook for derived classes to change the value returned.
See also
get() for more details.
Parameters
__begβ Start of input stream.__endβ End of input stream.__ioβ Source of locale and flags.__errβ Error flags to set.__vβ Value to format and insert.
Returns
Iterator after reading.
template<typename _CharT, typename _InIter> _InIter std::num_get< _CharT, _InIter >::do_get (iter_type __beg, iter_type __end, ios_base & __io, ios_base::iostate & __err, bool & __v) const [protected], [virtual]
Numeric parsing. Parses the input stream into the variable v. This function is a hook for derived classes to change the value returned.
See also
get() for more details.
and that's where part 1 wraps up, bestie β no sign-off yet, we're only getting started β¨
Parameters
__begβ Start of input stream.__endβ End of input stream.__ioβ Source of locale and flags.__errβ Error flags to set.__vβ Value to format and insert.
Returns
Iterator after reading. β¨
References
std::ios_base::_M_getloc(), std::ios_base::boolalpha, std::ios_base::eofbit, std::ios_base::failbit, std::ios_base::flags(), and std::ios_base::goodbit.
Referenced by
std::num_get< _CharT, istreambuf_iterator< _CharT, _Traits > >::get()std::num_get< _CharT, istreambuf_iterator< _CharT, _Traits > >::get()std::num_get< _CharT, istreambuf_iterator< _CharT, _Traits > >::get()std::num_get< _CharT, istreambuf_iterator< _CharT, _Traits > >::get()std::num_get< _CharT, istreambuf_iterator< _CharT, _Traits > >::get()std::num_get< _CharT, istreambuf_iterator< _CharT, _Traits > >::get()std::num_get< _CharT, istreambuf_iterator< _CharT, _Traits > >::get()std::num_get< _CharT, istreambuf_iterator< _CharT, _Traits > >::get()std::num_get< _CharT, istreambuf_iterator< _CharT, _Traits > >::get()std::num_get< _CharT, istreambuf_iterator< _CharT, _Traits > >::get()std::num_get< _CharT, istreambuf_iterator< _CharT, _Traits > >::get()
bestie yes it's the same line eleven times π that is genuinely what the docs say, they're just Like That, and we do not edit the source. eleven. times. π
do_get β the double one π
template<typename _CharT, typename _InIter> _InIter std::num_get< _CharT, _InIter >::do_get (iter_type __beg, iter_type __end, ios_base & __io, ios_base::iostate & __err, double & __v) const [protected], [virtual]
Numeric parsing. It takes your input stream and parses it straight into the variable v. This one is a hook β a little trapdoor that derived classes can use to change the value that gets returned. customisation slay β¨
See also
get() for more details β go peek at it, it's got the full lore.
Parameters
__begβ Start of input stream.__endβ End of input stream.__ioβ Source of locale and flags.__errβ Error flags to set.__vβ Value to format and insert.
Returns
Iterator after reading. π
References
std::basic_string< _CharT, _Traits, _Alloc >::c_str(), std::ios_base::eofbit, and std::basic_string< _CharT, _Traits, _Alloc >::reserve().
do_get β the float one π¦
template<typename _CharT, typename _InIter> _InIter std::num_get< _CharT, _InIter >::do_get (iter_type __beg, iter_type __end, ios_base & __io, ios_base::iostate & __err, float & __v) const [protected], [virtual]
Numeric parsing. Parses the input stream into the variable v. Same deal as the others β it's a hook so derived classes can swap out what comes back. no cap, same energy, different type π«Ά
See also
get() for more details.
Parameters
__begβ Start of input stream.__endβ End of input stream.__ioβ Source of locale and flags.__errβ Error flags to set.__vβ Value to format and insert.
Returns
Iterator after reading. β
References
std::basic_string< _CharT, _Traits, _Alloc >::c_str(), std::ios_base::eofbit, and std::basic_string< _CharT, _Traits, _Alloc >::reserve().
do_get β the long double one π
template<typename _CharT, typename _InIter> _InIter std::num_get< _CharT, _InIter >::do_get (iter_type __beg, iter_type __end, ios_base & __io, ios_base::iostate & __err, long double & __v) const [protected], [virtual]
Numeric parsing. Parses the input stream into the variable v. Hook for derived classes to change the returned value, yes bestie, exactly like the last two. the template really said copy-paste-and-thrive π
See also
get() for more details.
Parameters
__begβ Start of input stream.__endβ End of input stream.__ioβ Source of locale and flags.__errβ Error flags to set.__vβ Value to format and insert.
Returns
Iterator after reading. πΈ
References
std::basic_string< _CharT, _Traits, _Alloc >::c_str(), std::ios_base::eofbit, and std::basic_string< _CharT, _Traits, _Alloc >::reserve().
do_get β the void *& one π₯
template<typename _CharT, typename _InIter> _InIter std::num_get< _CharT, _InIter >::do_get (iter_type __beg, iter_type __end, ios_base & __io, ios_base::iostate & __err, void *& __v) const [protected], [virtual]
Numeric parsing. Parses the input stream into the variable v. Hook for derived classes to change the value returned. a whole pointer, getting parsed, in this economy π iconic honestly
See also
get() for more details.
Parameters
__begβ Start of input stream.__endβ End of input stream.__ioβ Source of locale and flags.__errβ Error flags to set.__vβ Value to format and insert.
Returns
Iterator after reading. π
References
std::ios_base::basefield, std::ios_base::flags(), and std::ios_base::hex.
get β the bool & one π
template<typename _CharT, typename _InIter> iter_type std::num_get< _CharT, _InIter >::get (iter_type __in, iter_type __end, ios_base & __io, ios_base::iostate & __err, bool & __v) const [inline]
Numeric parsing. Parses the input stream into the bool v. How? By calling num_get::do_get(). delegation, we love to see it β¨
Here's the actual tea, bestie:
- If
ios_base::boolalphais set, it tries to readctype<CharT>::truename()orctype<CharT>::falsename(). If it works, it setsvtotrueorfalse. If reading the string fails, it setserrtoios_base::failbit. And if the stream gets emptied, it setserrtoios_base::eofbit. - If
ios_base::boolalphais not set, it proceeds like it's reading alongβ except: if the value is1it setsvtotrue, if the value is0it setsvtofalse, and otherwise it setserrtoios_base::failbit. not 0, not 1? failbit. no in-between, periodt.
Parameters
__inβ Start of input stream.__endβ End of input stream.__ioβ Source of locale and flags.__errβ Error flags to set.__vβ Value to format and insert.
Returns
Iterator after reading. π¦
Referenced by
std::basic_istream< _CharT, _Traits >::operator>>().
get β the double & one π
template<typename _CharT, typename _InIter> iter_type std::num_get< _CharT, _InIter >::get (iter_type __in, iter_type __end, ios_base & __io, ios_base::iostate & __err, double & __v) const [inline]
Numeric parsing. Parses the input stream into the integral variable v. And it does it by calling num_get::do_get(). (yes, the docs say "integral" here even though it's a double. we report, we don't fix π)
The input characters are parsed like the scanf g specifier. The matching type length modifier is also used too.
The decimal point character used is numpunct::decimal_point(). Digit grouping gets interpreted according to numpunct::grouping() and numpunct::thousands_sep(). And if the pattern of digit groups isn't consistent, it sets err to ios_base::failbit. inconsistent grouping = straight to failbit jail π¨
If parsing the string gives you a valid value for v, then v is set. Otherwise it sets err to ios_base::failbit and leaves v unaltered β untouched, unbothered, exactly as it was. π If the stream is emptied, it sets err to ios_base::eofbit.
Parameters
__inβ Start of input stream.__endβ End of input stream.__ioβ Source of locale and flags.__errβ Error flags to set.__vβ Value to format and insert.
Returns
Iterator after reading. π
get β the float & one π§
template<typename _CharT, typename _InIter> iter_type std::num_get< _CharT, _InIter >::get (iter_type __in, iter_type __end, ios_base & __io, ios_base::iostate & __err, float & __v) const [inline]
Numeric parsing. Parses the input stream into the integral variable v, by calling num_get::do_get(). same "integral" wording, same chaos, we move π
The input characters are parsed like the scanf g specifier, and the matching type length modifier is also used.
Decimal point character = numpunct::decimal_point(). Digit grouping follows numpunct::grouping() and numpunct::thousands_sep(). If the digit-group pattern isn't consistent β err gets ios_base::failbit.
Valid value for v? Then v is set. Not valid? err gets ios_base::failbit and v stays unaltered. Stream emptied? err gets ios_base::eofbit. β¨
Parameters
__inβ Start of input stream.__endβ End of input stream.__ioβ Source of locale and flags.__errβ Error flags to set.__vβ Value to format and insert.
Returns
Iterator after reading. π
get β the long & one π₯
template<typename _CharT, typename _InIter> iter_type std::num_get< _CharT, _InIter >::get (iter_type __in, iter_type __end, ios_base & __io, ios_base::iostate & __err, long & __v) const [inline]
Numeric parsing. Parses the input stream into the integral variable v. Calls num_get::do_get() to do it.
Parsing is affected by the flag settings in io. π
The basic parse is affected by the value of io.flags() & ios_base::basefield:
- Equal to
ios_base::octβ parses like thescanfospecifier. - Else if equal to
ios_base::hexβ parses like theXspecifier. - Else if
basefieldis equal to0β parses like theispecifier. - Otherwise β parses like
dfor signed andufor unsigned types.
The matching type length modifier is also used.
Digit grouping is interpreted according to numpunct::grouping() and numpunct::thousands_sep(). If the pattern of digit groups isn't consistent, sets err to ios_base::failbit. consistent grouping or failbit, there is no third option bestie
If parsing the string yields a valid value for v, v is set. Otherwise, sets err to ios_base::failbit and leaves v unaltered. Sets err to ios_base::eofbit if the stream is emptied. πΈ
Parameters
__inβ Start of input stream.__endβ End of input stream.__ioβ Source of locale and flags.__errβ Error flags to set.__vβ Value to format and insert.
Returns
Iterator after reading. β
get β the long double & one π
template<typename _CharT, typename _InIter> iter_type std::num_get< _CharT, _InIter >::get (iter_type __in, iter_type __end, ios_base & __io, ios_base::iostate & __err, long double & __v) const [inline]
Numeric parsing. Parses the input stream into the integral variable v, by calling num_get::do_get().
Input characters are parsed like the scanf g specifier. The matching type length modifier is also used.
Decimal point character used is numpunct::decimal_point(). Digit grouping is interpreted according to numpunct::grouping() and numpunct::thousands_sep(). Inconsistent digit-group pattern β err gets ios_base::failbit. π€
Valid value for v β v is set. Otherwise err gets ios_base::failbit and v is left unaltered. Stream emptied β err gets ios_base::eofbit. π«Ά
Parameters
__inβ Start of input stream.__endβ End of input stream.__ioβ Source of locale and flags.__errβ Error flags to set.__vβ Value to format and insert.
Returns
Iterator after reading. π
get β the long long & one π§
template<typename _CharT, typename _InIter> iter_type std::num_get< _CharT, _InIter >::get (iter_type __in, iter_type __end, ios_base & __io, ios_base::iostate & __err, long long & __v) const [inline]
Numeric parsing. Parses the input stream into the integral variable v. Yep β by calling num_get::do_get().
Parsing is affected by the flag settings in io.
The basic parse is affected by the value of io.flags() & ios_base::basefield:
- Equal to
ios_base::octβ parses like thescanfospecifier. - Else if equal to
ios_base::hexβ parses like theXspecifier. - Else if
basefieldis equal to0β parses like theispecifier. - Otherwise β parses like
dfor signed andufor unsigned types.
The matching type length modifier is also used. π
and that's where this part of the page cuts off β more coming, don't go anywhere bestie π«Ά
Digit grouping</p> is read through numpunct::grouping() and numpunct::thousands_sep(), okay? And if the pattern of digit groups isn't consistent β like, the groups don't follow the vibe β it sets err to ios_base::failbit. π«
If parsing the string yields a valid value for v, then v is set. Otherwise it sets err to ios_base::failbit and leaves v unaltered, untouched, not a single change, bestie. And it sets err to ios_base::eofbit if the stream is emptied. That's the whole drama. π
Parameters
__inβ start of input stream, the beginning of the journey β¨__endβ end of input stream, the finish line π__ioβ source of locale and flags, the whole setup__errβ error flags to set, where the bad news goes__vβ value to format and insert
Returns
Iterator after reading. That's it, that's the return. πΈ
template<typename _CharT, typename _InIter> iter_type std::num_get< _CharT, _InIter >::get (iter_type __in, iter_type __end, ios_base & __io, ios_base::iostate & __err, unsigned long & __v) const [inline]
Numeric parsing, round two, and this time it's unsigned long. It parses the input stream into the integral variable v, and the way it does that is by calling num_get::do_get(). Lowkey just delegating, and honestly? Valid. π
The parsing is affected by the flag settings in io.
The basic parse is affected by the value of io.flags() & ios_base::basefield. So:
- If it's equal to
ios_base::oct, it parses like thescanfospecifier. - Else if it's equal to
ios_base::hex, it parses like theXspecifier. - Else if
basefieldis equal to0, it parses like theispecifier. - Otherwise, it parses like
dfor signed types andufor unsigned types.
And the matching type length modifier is also used. No skipping steps. β¨
Digit grouping is interpreted according to numpunct::grouping() and numpunct::thousands_sep(). If the pattern of digit groups isn't consistent, it sets err to ios_base::failbit.
If parsing the string yields a valid value for v, v is set. Otherwise, err gets ios_base::failbit and v is left unaltered. And if the stream gets emptied, err is set to ios_base::eofbit. π¦
Parameters
__inβ start of input stream__endβ end of input stream__ioβ source of locale and flags__errβ error flags to set__vβ value to format and insert
Returns
Iterator after reading. π
template<typename _CharT, typename _InIter> iter_type std::num_get< _CharT, _InIter >::get (iter_type __in, iter_type __end, ios_base & __io, ios_base::iostate & __err, unsigned long long & __v) const [inline]
Numeric parsing again, now for unsigned long long. Parses the input stream into the integral variable v, by calling num_get::do_get(). Same energy, bigger number. π₯
Parsing is affected by the flag settings in io.
The basic parse is affected by the value of io.flags() & ios_base::basefield:
- Equal to
ios_base::oct? Parses like thescanfospecifier. - Else equal to
ios_base::hex? Parses like theXspecifier. - Else
basefieldequal to0? Parses like theispecifier. - Otherwise? Parses like
dfor signed andufor unsigned types.
Plus the matching type length modifier is also used. π«
Digit grouping is interpreted according to numpunct::grouping() and numpunct::thousands_sep(). If the pattern of digit groups isn't consistent, sets err to ios_base::failbit.
If parsing the string yields a valid value for v, v is set. Otherwise sets err to ios_base::failbit and leaves v unaltered. Sets err to ios_base::eofbit if the stream is emptied. π
Parameters
__inβ start of input stream__endβ end of input stream__ioβ source of locale and flags__errβ error flags to set__vβ value to format and insert
Returns
Iterator after reading. π
template<typename _CharT, typename _InIter> iter_type std::num_get< _CharT, _InIter >::get (iter_type __in, iter_type __end, ios_base & __io, ios_base::iostate & __err, unsigned short & __v) const [inline]
Numeric parsing, but smol this time β unsigned short. Parses the input stream into the integral variable v by calling num_get::do_get(). Same brain, tinier box. π
Parsing is affected by the flag settings in io.
The basic parse is affected by the value of io.flags() & ios_base::basefield:
- If equal to
ios_base::oct, parses like thescanfospecifier. - Else if equal to
ios_base::hex, parses like theXspecifier. - Else if
basefieldequal to0, parses like theispecifier. - Otherwise, parses like
dfor signed andufor unsigned types.
The matching type length modifier is also used, obviously. π
Digit grouping is interpreted according to numpunct::grouping() and numpunct::thousands_sep(). If the pattern of digit groups isn't consistent, sets err to ios_base::failbit.
If parsing the string yields a valid value for v, v is set. Otherwise, sets err to ios_base::failbit and leaves v unaltered. Sets err to ios_base::eofbit if the stream is emptied. πΈ
Parameters
__inβ start of input stream__endβ end of input stream__ioβ source of locale and flags__errβ error flags to set__vβ value to format and insert
Returns
Iterator after reading. π§
template<typename _CharT, typename _InIter> iter_type std::num_get< _CharT, _InIter >::get (iter_type __in, iter_type __end, ios_base & __io, ios_base::iostate & __err, void *& __v) const [inline]
Okay bestie, this one's the pointer one, and it's a whole different flavor. Numeric parsing β it parses the input stream into the pointer variable v, and yes, it does so by calling num_get::do_get(). π
The input characters are parsed like the scanf p specifier. Periodt.
Digit grouping is interpreted according to numpunct::grouping() and numpunct::thousands_sep(). If the pattern of digit groups isn't consistent, sets err to ios_base::failbit.
β οΈ Real talk: the digit grouping effect for pointers is a bit ambiguous in the standard and shouldn't be relied on. See DR 344. Do not build your whole life on it. π
If parsing the string yields a valid value for v, v is set. Otherwise, sets err to ios_base::failbit and leaves v unaltered. Sets err to ios_base::eofbit if the stream is emptied. π
Parameters
__inβ start of input stream__endβ end of input stream__ioβ source of locale and flags__errβ error flags to set__vβ value to format and insert
Returns
Iterator after reading. β¨
π Member Data Documentation π
template<typename _CharT, typename _InIter> locale::id std::num_get< _CharT, _InIter >::id [static]
Numpunct facet id. That's the whole thing, she's short and she knows it. π
π Author π
Generated automatically by Doxygen for libstdc++ from the source code. Not a human, not a vibe curator, just Doxygen doing its lil thing. π«Ά
And that's a wrap on this one, bestie! This whole page comes to you from the libstdc++ manual β that's the source and the version, right there in the footer, along with the page name std::num_g..., _InIter >(3). So if you ever need to cite it: libstdc++, std::num_g..., _InIter >(3). Slay, go parse something. πβ¨π
π¦ where this page comes from
- arch rolling: gcc 16.2.1+r23+gd564253eb6c8-1 Β· GPL-3.0-or-later WITH GCC-exception-3.1 AND GFDL-1.3-or-later
- centos-stream 10: gcc-toolset-16-libstdc++-docs 16.2.1-1.3.el10 Β· GPL-3.0-or-later AND LGPL-3.0-or-later AND (GPL-3.0-or-later WITH GCC-exception-3.1) AND (GPL-3.0-or-later WITH Texinfo-exception) AND (LGPL-2.1-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GNU-compiler-exception) AND BSL-1.0 AND GFDL-1.3-or-later AND Linux-man-pages-copyleft-2-para AND SunPro AND BSD-1-Clause AND BSD-2-Clause AND BSD-2-Clause-Views AND BSD-3-Clause AND BSD-4-Clause AND BSD-Source-Code AND Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 WITH LLVM-Exception) AND ZPL-2.1 AND ISC AND LicenseRef-Fedora-Public-Domain AND HP-1986 AND curl AND Martin-Birgmeier AND HPND-Markus-Kuhn AND dtoa AND SMLNJ AND AMD-newlib AND OAR AND HPND-merchantability-variant AND HPND-Intel
- fedora 44: libstdc++-docs 16.2.1-2.fc44
- fedora 44: libstdc++-docs 16.2.1-3.fc44 Β· GPL-3.0-or-later AND LGPL-3.0-or-later AND (GPL-3.0-or-later WITH GCC-exception-3.1) AND (GPL-3.0-or-later WITH Texinfo-exception) AND (LGPL-2.1-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GNU-compiler-exception) AND BSL-1.0 AND GFDL-1.3-or-later AND Linux-man-pages-copyleft-2-para AND SunPro AND BSD-1-Clause AND BSD-2-Clause AND BSD-2-Clause-Views AND BSD-3-Clause AND BSD-4-Clause AND BSD-Source-Code AND Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 WITH LLVM-Exception) AND ZPL-2.1 AND ISC AND LicenseRef-Fedora-Public-Domain AND HP-1986 AND curl AND Martin-Birgmeier AND HPND-Markus-Kuhn AND dtoa AND SMLNJ AND AMD-newlib AND OAR AND HPND-merchantability-variant AND HPND-Intel
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms