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, ...

Get C++ In a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.