Name

money_put class template — Facet for output of monetary values

Synopsis

template <typename charT,
  typename OutputIterator = ostreambuf_iterator<charT> >
class money_put : public locale::facet
{
public:
  typedef charT char_type;
  typedef OutputIterator iter_type;
  typedef basic_string<charT> string_type;
  explicit money_put(size_t refs = 0);
  iter_type put(iter_type s, bool intl, ios_base& f, char_type fill, 
                long double units) const;
  iter_type put(iter_type s, bool intl, ios_base& f, char_type fill, 
                const string_type& digits) const;
  static locale::id id;
protected:
  virtual ~money_put(  );
  virtual iter_type do_put(iter_type, bool, ios_base&, char_type fill, 
                           long double units) const;
  virtual iter_type do_put(iter_type, bool, ios_base&, char_type fill, 
                           const string_type& digits) const;
};

The money_put class template is a facet for formatting and printing monetary values. See Example 13-27 (under money_get), which shows how to use the money_put facet. The money_put<char> and money_put<wchar_t> instantiations are standard.

As with other facets, the public members call virtual, protected members with the same name prefaced by do_. Thus, to use the facet, call the public functions, such as put, which calls do_put. The descriptions below are for the virtual functions because they do the real work. Imagine that for each virtual function description, there is a corresponding description for a public, nonvirtual function, such as:

iter_type put (iter_type iter, bool intl, ios_base& stream, char_type ...

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.