public:
iter_type get(iter_type in, iter_type end, ios_base& str,
ios_base::iostate& err, bool& val) const; // (1) C++98
iter_type get(iter_type in, iter_type end, ios_base& str,
ios_base::iostate& err, long& val) const; // (2) C++98
iter_type get(iter_type in, iter_type end, ios_base& str,
ios_base::iostate& err, long long& val) const; // (3) C++11
iter_type get(iter_type in, iter_type end, ios_base& str,
ios_base::iostate& err, unsigned short& val) const; // (4) C++98
iter_type get(iter_type in, iter_type end, ios_base& str,
ios_base::iostate& err, unsigned int& val) const; // (5) C++98
iter_type get(iter_type in, iter_type end, ios_base& str,
ios_base::iostate& err, unsigned long& val) const; // (6) C++98
iter_type get(iter_type in, iter_type end, ios_base& str,
ios_base::iostate& err, unsigned long long& val) const; // (7) C++11
iter_type get(iter_type in, iter_type end, ios_base& str,
ios_base::iostate& err, float& val) const; // (8) C++98
iter_type get(iter_type in, iter_type end, ios_base& str,
ios_base::iostate& err, double& val) const; // (9) C++98
iter_type get(iter_type in, iter_type end, ios_base& str,
ios_base::iostate& err, long double& val) const; // (10) C++98
iter_type get(iter_type in, iter_type end, ios_base& str,
ios_base::iostate& err, void*& val) const; // (11) C++98
概要
入力イテレータ範囲[in, end)から文字列を読み取り、valの型に応じた数値・真偽値・ポインタへ変換する。
- (1) :
boolへ変換する - (2), (3) : 符号付き整数型 (
long,long long) へ変換する - (4), (5), (6), (7) : 符号なし整数型 (
unsigned short,unsigned int,unsigned long,unsigned long long) へ変換する - (8), (9), (10) : 浮動小数点数型 (
float,double,long double) へ変換する - (11) : ポインタ (
void*) へ変換する
効果
- (1)〜(11) :
do_get(in, end, str, err, val)を呼び出す
戻り値
例
#include <iostream>
#include <sstream>
#include <locale>
#include <iterator>
int main()
{
std::istringstream iss{"42"};
auto& facet = std::use_facet<std::num_get<char>>(iss.getloc());
long value = 0;
std::ios_base::iostate err = std::ios_base::goodbit;
std::istreambuf_iterator<char> begin{iss}, end{};
facet.get(begin, end, iss, err, value);
std::cout << value << std::endl;
}
出力
42
バージョン
言語
- C++98