O'Reilly logo

C++ In a Nutshell by Ray Lischner

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

num_put class template — Facet for output of numbers

Synopsis

template <typename charT,
          typename OutputIterator = ostreambuf_iterator<charT> >
class num_put : public locale::facet
{
public:
  typedef charT char_type;
  typedef OutputIterator iter_type;
  explicit num_put(size_t refs = 0);
  iter_type put(iter_type s, ios_base& f, char_type fill, bool v) const;
  iter_type put(iter_type s, ios_base& f, char_type fill, long v) const;
  iter_type put(iter_type s, ios_base& f, char_type fill, unsigned long v) const;
  iter_type put(iter_type s, ios_base& f, char_type fill, double v) const;
  iter_type put(iter_type s, ios_base& f, char_type fill, long double v) const;
  iter_type put(iter_type s, ios_base& f, char_type fill, const void* v) const;
  static locale::id id;
protected:
  virtual ~num_put(  );
  virtual iter_type do_put(iter_type, ios_base&, char_type fill, bool v) const;
  virtual iter_type do_put(iter_type, ios_base&, char_type fill, long v) const;
  virtual iter_type do_put(iter_type, ios_base&, char_type fill, unsigned long)
    const;
  virtual iter_type do_put(iter_type, ios_base&, char_type fill, double v) const;
  virtual iter_type do_put(iter_type, ios_base&, char_type fill, long double v)
    const;
  virtual iter_type do_put(iter_type, ios_base&, char_type fill, const void* v)
    const;
};

The num_put class template is a facet for formatting and outputing a numeric value. The ostream output operators (>>) use num_put. The num_put<char> and num_put<wchar_t> instantiations are standard.

As with other facets, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required