std::num_get::get, std::num_get::do_get

From Cppreference

Jump to: navigation, search
Defined in header <locale>

public:

iter_type get( iter_type in, iter_type end, std::ios_base& str, std::ios_base::iostate& err, bool& v )
iter_type get( iter_type in, iter_type end, std::ios_base& str, std::ios_base::iostate& err, long& v )
iter_type get( iter_type in, iter_type end, std::ios_base& str, std::ios_base::iostate& err, long long& v )
iter_type get( iter_type in, iter_type end, std::ios_base& str, std::ios_base::iostate& err, unsigned short& v )
iter_type get( iter_type in, iter_type end, std::ios_base& str, std::ios_base::iostate& err, unsigned int& v )
iter_type get( iter_type in, iter_type end, std::ios_base& str, std::ios_base::iostate& err, unsigned long& v )
iter_type get( iter_type in, iter_type end, std::ios_base& str, std::ios_base::iostate& err, unsigned long long& v )
iter_type get( iter_type in, iter_type end, std::ios_base& str, std::ios_base::iostate& err, float& v )
iter_type get( iter_type in, iter_type end, std::ios_base& str, std::ios_base::iostate& err, double& v )
iter_type get( iter_type in, iter_type end, std::ios_base& str, std::ios_base::iostate& err, long double& v )

iter_type get( iter_type in, iter_type end, std::ios_base& str, std::ios_base::iostate& err, void*& v )
(1)
protected:

iter_type do_get(iter_type in, iter_type end, std::ios_base& str, std::ios_base::iostate& err, bool& v )
iter_type do_get(iter_type in, iter_type end, std::ios_base& str, std::ios_base::iostate& err, long& v )
iter_type do_get(iter_type in, iter_type end, std::ios_base& str, std::ios_base::iostate& err, long long& v )
iter_type do_get(iter_type in, iter_type end, std::ios_base& str, std::ios_base::iostate& err, unsigned short& v )
iter_type do_get(iter_type in, iter_type end, std::ios_base& str, std::ios_base::iostate& err, unsigned int& v )
iter_type do_get(iter_type in, iter_type end, std::ios_base& str, std::ios_base::iostate& err, unsigned long& v )
iter_type do_get(iter_type in, iter_type end, std::ios_base& str, std::ios_base::iostate& err, unsigned long long& v )
iter_type do_get(iter_type in, iter_type end, std::ios_base& str, std::ios_base::iostate& err, float& v )
iter_type do_get(iter_type in, iter_type end, std::ios_base& str, std::ios_base::iostate& err, double& v )
iter_type do_get(iter_type in, iter_type end, std::ios_base& str, std::ios_base::iostate& err, long double& v )

iter_type do_get(iter_type in, iter_type end, std::ios_base& str, std::ios_base::iostate& err, void*& v )
(2)

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 IO 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

Contents

[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] Stage 2: character extraction

[edit] Stage 3: conversion and storage

[edit] Return value

in

[edit] Notes

In C++98/C++03, if an error occurs, v is left unchanged. In C++11, it is set to a value as described above.

[edit] Example

[edit] See also

extracts formatted data
(public member function of std::basic_istream)