12 Aralık 2016 Pazartesi

std::num_get facet

Giriş
Şu satırı dahil ederiz.
#include <locale>
Açıklaması şöyle
Class std::num_get encapsulates the rules for parsing string representations of numeric values. Specifically, types bool, unsigned short, unsigned int, long, unsigned long, long long, unsigned long long, float, double, long double, and void* are supported. The standard formatting input operators (such as cin >> n;) use the std::num_get facet of the I/O stream's locale to parse the text representations of the numbers.
Kendi Sınıfım
Şöyle yaparız.
template <class charT, class InputIterator = istreambuf_iterator<charT> >
class read_num : public std::num_get < charT > {

public:
  typedef charT char_type;
  typedef InputIterator iter_type;

protected:
  iter_type do_get(iter_type in, iter_type end, ios_base& str,
    ios_base::iostate& err, double& val) const {
   
    return in;
  }
};

Hiç yorum yok:

Yorum Gönder