STD::NUM_GET(3cxx)
π
std::num_get< _CharT, _InIter > β the C++ standard library manual, page (3cxx)
okay so bestie, welcome to the glow-up era of this page. It's std::num_get< _CharT, _InIter >, from the (3cxx) section of the manual β i.e. the C++ standard library docs β and she's the fairy godmother who turns your messy string of characters into an actual number. Periodt. Let's get into it π
β¨ NAME β¨
std::num_get< _CharT, _InIter > β the Primary class template num_get. That's her. That's the whole name. Iconic, lowkey.
β¨ SYNOPSIS β¨
#include <locale>
Inherits from std::locale::facet. So she's a facet, she's got the family connections, she belongs to the locale. Main character energy fr fr π
πΈ Public Types
typedef _CharT char_typeβ "Public typedefs." aka the character type she's working with, slay.typedef _InIter iter_typeβ "Public typedefs." aka the iterator type she takes in and hands back, obsessed.
πΈ Public Member Functions
num_get (size_t __refs=0)β Constructor performs initialization. (Yes, that's what it says, and yes, that is genuinely what a constructor does π)template<typename _ValueT > _InIter _M_extract_int (_InIter __beg, _InIter __end, ios_base &__io, ios_base::iostate &__err, _ValueT &__v) constβ the internal integer-extracting bestie.iter_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.
and then the whole group chat of get overloads, all of them Numeric parsing, all of them carrying:
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.
and then the floaties π :
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." She has an id. She's that girl. π¦
πΈ Protected Member Functions
virtual ~num_get ()β Destructor. (the sad part π)iter_type _M_extract_float (iter_type, iter_type, ios_base &, ios_base::iostate &, string &) constβ the float-extracting machinery, protected, mysterious, doing her thing.template<typename _ValueT > iter_type _M_extract_int (iter_type, iter_type, ios_base &, ios_base::iostate &, _ValueT &) constβ same energy, but for ints.
and these two absolute legends with the wildest signatures on the whole page:
template<typename _CharT2 > __gnu_cxx::__enable_if< __is_char< _CharT2 >::__value, int >::__type _M_find (const _CharT2 *, size_t __len, _CharT2 __c) const
template<typename _CharT2 > __gnu_cxx::__enable_if<!__is_char< _CharT2 >::__value, int >::__type _M_find (const _CharT2 *__zero, size_t __len, _CharT2 __c) const
no cap, I am not explaining that any further than the page does, because the page doesn't. It's giving SFINAE, it's giving __enable_if, it's giving iykyk π
then the do_get girlies, every single one of them virtual, every single one of them Numeric parsing:
virtual 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
the C-locale management crew, all static, all protected, all doing the behind-the-scenes work so you don't have to:
static __c_locale _S_clone_c_locale (__c_locale &__cloc) throw ()β clones the C locale.static void _S_create_c_locale (__c_locale &__cloc, const char *__s, __c_locale __old=0)β creates a C locale, with__olddefaulting to0.static void _S_destroy_c_locale (__c_locale &__cloc)β destroys it. bye bestie πstatic __c_locale _S_get_c_locale ()β grabs the C locale.static const char * _S_get_c_name () throw ()β grabs the C locale's name, as aconst char *.static __c_locale _S_lc_ctype_c_locale (__c_locale __cloc, const char *__s)β theLC_CTYPE-flavored C locale getter.
π¦ Detailed Description π¦
template<typename _CharT, typename _InIter>
class std::num_get< _CharT, _InIter >
She's the Primary class template num_get.
So what does she actually do? This facet encapsulates the code to parse and return a number from a string. That's it. That's her whole job. It is used by the istream numeric extraction operators β so when you do the >> thing and pull a number out of a stream, she's the one behind the curtain making it happen. π
The num_get template uses protected virtual functions to provide the actual results. The public accessors forward the call to the virtual functions. These virtual functions are hooks for developers to implement the behavior they require from the num_get facet.
Translation for the besties: public get() = the front door, protected virtual do_get() = the actual work room, and you're allowed to redecorate the work room because they're hooks. Slay.
π Member Typedef Documentation π
template<typename _CharT , typename _InIter > typedef _CharT std::num_get< _CharT, _InIter >::char_type
Public typedefs. That's the entire note. She said what she said β¨
template<typename _CharT , typename _InIter > typedef _InIter std::num_get< _CharT, _InIter >::iter_type
Public typedefs. Again. Same energy. Same three words. We love a consistent queen π
π 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. She's explicit, she's inline, she's initialized, she's ready.
Parameters:
__refsβ Passed to the base facet class.
That's the whole parameter list. One (1) parameter. She's low maintenance π«Ά
template<typename _CharT , typename _InIter > virtual std::num_get< _CharT, _InIter >::~num_get () [inline], [protected], [virtual]
Destructor. Also inline, also protected, also virtual. She leaves the group chat the same way she joined it: with three qualifiers. π
π₯ Member Function Documentation π₯
okay so here's where it gets repetitive in the most loyal, thorough way possible, because every single do_get overload gets its own writeup and they all say the exact same thing. Respect the grind. π₯
Every one of these is Numeric parsing. Parses the input stream into the variablev. This function is a hook for derived classes to change the value returned. And every single one says See alsoget()for more details.
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.
(and yes, the bool one is where this part of the page stops β part 2 is coming, don't you dare touch that dial π)
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::_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, _InIter >::get(), std::num_get< _CharT, _InIter >::get(), std::num_get< _CharT, _InIter >::get(), std::num_get< _CharT, _InIter >::get(), std::num_get< _CharT, _InIter >::get(), std::num_get< _CharT, _InIter >::get(), std::num_get< _CharT, _InIter >::get(), std::num_get< _CharT, _InIter >::get(), std::num_get< _CharT, _InIter >::get(), std::num_get< _CharT, _InIter >::get(), and std::num_get< _CharT, _InIter >::get().
do_get for double π
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. Parses the input stream into the variable v. This function is a hook for derived classes to change the value returned.
bestie, it's literally a hook β you override it if you want custom parsing behavior. no cap. πͺ
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 for float π
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. 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.
References std::basic_string< _CharT, _Traits, _Alloc >::c_str(), std::ios_base::eofbit, and std::basic_string< _CharT, _Traits, _Alloc >::reserve().
do_get for long double πΈ
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. 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.
References std::basic_string< _CharT, _Traits, _Alloc >::c_str(), std::ios_base::eofbit, and std::basic_string< _CharT, _Traits, _Alloc >::reserve().
do_get for void* π
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. 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.
References std::ios_base::basefield, std::ios_base::flags(), and std::ios_base::hex.
get for bool π¦
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. It does so by calling num_get::do_get().
If ios_base::boolalpha is set, attempts to read ctype<CharT>::truename() or ctype<CharT>::falsename(). Sets v to true or false if successful. Sets err to ios_base::failbit if reading the string fails. Sets err to ios_base::eofbit if the stream is emptied.
If ios_base::boolalpha is not set, proceeds as with reading a long, except if the value is 1, sets v to true, if the value is 0, sets v to false, and otherwise set err to ios_base::failbit.
so like, boolalpha is the difference between reading "true"/"false" and reading "1"/"0". got it? π
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.
References std::num_get< _CharT, _InIter >::do_get().
get for double β¨
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. It does so by calling num_get::do_get().
yes bestie, it says βintegral variableβ for a double. thatβs what the page says. i donβt make the rules π
The input characters are parsed like the scanf g specifier. The matching type length modifier is also used.
The decimal point character used is numpunct::decimal_point(). 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.
References std::num_get< _CharT, _InIter >::do_get().
get for float π
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. It does so by calling num_get::do_get().
The input characters are parsed like the scanf g specifier. The matching type length modifier is also used.
The decimal point character used is numpunct::decimal_point(). 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.
References std::num_get< _CharT, _InIter >::do_get().
get for long π₯
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. It does so 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. If equal to ios_base::oct, parses like the scanf o specifier. Else if equal to ios_base::hex, parses like X specifier. Else if basefield equal to 0, parses like the i specifier. Otherwise, parses like d for signed and u for 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.
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.
basefield is the vibe check for octal/hex/decimal. slay. π
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.
References std::num_get< _CharT, _InIter >::do_get().
get for long double π
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. It does so by calling num_get::do_get().
The input characters are parsed like the scanf g specifier. The matching type length modifier is also used.
The decimal point character used is numpunct::decimal_point(). 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.
References std::num_get< _CharT, _InIter >::do_get().
get for long long β
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. It does so 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. If equal to ios_base::oct, parses like the scanf o specifier. Else if equal to ios_base::hex, parses like X specifier. Else if basefield equal to 0, parses like the i specifier. Otherwise, parses like d for signed and u for 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.
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.
References std::num_get< _CharT, _InIter >::do_get().
...and if the parse lands you a valid value for v, bestie, v gets set. If not? err gets set to ios_base::failbit and v stays exactly as it was β untouched, unbothered, main character energy π
. Oh and if the stream gets emptied out, err gets ios_base::eofbit. That's the whole vibe check.
__inβ start of the input stream π¬__endβ end of the input stream π__ioβ the source of the locale and the flags β¨__errβ the error flags that get set π©__vβ the value to format and insert π«Ά
Returns: the iterator after reading. π
References: std::num_get< _CharT, _InIter >::do_get().
πΈ get β unsigned int & __v
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 int & __v) const [inline]
Okay so this one is numeric parsing, and what it does is parse the input stream into the integral variable v β by calling num_get::do_get(), the way it always does. π
The parsing is affected by the flag settings in io. Yep, all of it.
The basic parse is affected by the value of io.flags() & ios_base::basefield. So:
- if that equals
ios_base::oct, it parses like thescanfospecifier - else if it equals
ios_base::hex, it parses like theXspecifier - else if
basefieldequals0, it parses like theispecifier - otherwise, it parses like
dfor signed types andufor unsigned types
And the matching type length modifier is also used, obvs. β¨
Digit grouping gets interpreted according to numpunct::grouping() and numpunct::thousands_sep(). And listen β if the pattern of digit groups isn't consistent, it sets err to ios_base::failbit. So don't be out here grouping digits all willy-nilly, it's not the vibe. π
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. And it sets err to ios_base::eofbit if the stream is emptied.
__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. π
References: std::num_get< _CharT, _InIter >::do_get().
π¦ get β unsigned long & __v
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]
Same iconic setup, different type: numeric parsing, and it parses the input stream into the integral variable v via a call to num_get::do_get(). π«Ά
Parsing is affected by the flag settings in io. Always.
The basic parse depends on 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 if
basefieldequal to0β parses like theispecifier - otherwise β parses like
dfor signed andufor unsigned types
Plus the matching type length modifier is used too. Not optional, bestie.
Digit grouping is interpreted according to numpunct::grouping() and numpunct::thousands_sep(). If the pattern of digit groups isn't consistent, err gets ios_base::failbit. Consistency is literally the whole thing. π
Valid value for v? Then v is set. Not valid? err gets ios_base::failbit and v is left unaltered. Stream emptied? err gets ios_base::eofbit.
__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. π
References: std::num_get< _CharT, _InIter >::do_get().
π get β unsigned long long & __v
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]
The long long girlie of the family π§ β numeric parsing, parses the input stream into the integral variable v, does it by calling num_get::do_get().
Parsing is affected by the flag settings in io. Yes babe, again.
Basic parse is affected by the value of io.flags() & ios_base::basefield:
ios_base::octβ parses like thescanfospecifierios_base::hexβ parses like theXspecifierbasefieldequal to0β parses like theispecifier- otherwise β parses like
dfor signed andufor unsigned types
The matching type length modifier is also used, periodt.
Digit grouping is interpreted according to numpunct::grouping() and numpunct::thousands_sep(). If that pattern of digit groups isn't consistent β err gets ios_base::failbit. No cap.
If parsing yields a valid value for v, v is set. Otherwise err gets ios_base::failbit and v is left unaltered. If the stream is emptied, err gets ios_base::eofbit.
__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. π
References: std::num_get< _CharT, _InIter >::do_get().
π get β unsigned short & __v
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]
Tiny but mighty π β numeric parsing, parses the input stream into the integral variable v, 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
basefieldequal to0β parses like theispecifier - otherwise β parses like
dfor signed andufor unsigned types
And don't forget the matching type length modifier, it's used too. β¨
Digit grouping is interpreted according to numpunct::grouping() and numpunct::thousands_sep(). If the pattern of digit groups isn't consistent, err gets set to ios_base::failbit. That's the rule, iykyk.
Valid value for v? v is set. Otherwise β err gets ios_base::failbit, and v is left unaltered, fr fr. Stream emptied β err gets ios_base::eofbit.
__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. π
References: std::num_get< _CharT, _InIter >::do_get().
π₯ get β void *& __v
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]
The pointer one!! π Numeric parsing β it parses the input stream into the pointer variable v, and yes, it does that by calling num_get::do_get().
The input characters are parsed like the scanf p specifier. That's the whole mood here.
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.
β οΈ Okay heads up bestie β note that the digit grouping effect for pointers is a bit ambiguous in the standard and shouldn't be relied on. See DR 344. Like, it's giving "undefined behaviour adjacent", so don't build your whole app on it, k? π
If parsing the string yields a valid value for v, v is set. Otherwise, err gets ios_base::failbit and v is left unaltered. Sets err to ios_base::eofbit if the stream is emptied.
__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. π
References: std::num_get< _CharT, _InIter >::do_get().
π§ MEMBER DATA DOCUMENTATION π§
β id
template<typename _CharT , typename _InIter > locale::id
std::num_get< _CharT, _InIter >::id [static]
Numpunct facet id. That's it, that's the whole description β short and iconic, we love a concise queen. π
π AUTHOR π
Generated automatically by Doxygen for libstdc++ from the source code. Not me hand-typing it with tears in my eyes β a robot did it, slay. π€β¨
And that's the page, bestie!! π«Ά Go forth and parse responsibly. This little beauty came to you from libstdc++ (that's the source/version flex, and that std::num_get< _CharT, _InIter >(3cxx) up in the corner is the page + section situation) β dated whenever the manpage gen last ran. Stay hydrated, group your digits consistently, and never trust a pointer's thousands separator. πππ¦
π¦ where this page comes from
- ubuntu noble: libstdc++-14-doc 14-20240412-0ubuntu1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms