numpunct class template — Facet for punctuation of numbers
template <typename charT> class numpunct : public locale::facet { public: typedef charT char_type; typedef basic_string<charT> string_type; explicit numpunct(size_t refs = 0); char_type decimal_point( ) const; char_type thousands_sep( ) const; string grouping( ) const; string_type truename( ) const; string_type falsename( ) const; static locale::id id; protected: virtual ~numpunct( ); virtual char_type do_decimal_point( ) const; virtual char_type do_thousands_sep( ) const; virtual string do_grouping( ) const; virtual string_type do_truename( ) const; virtual string_type do_falsename( ) const; };
The numpunct
class template
is a facet for numeric formatting and punctuation. The num_get
and num_put
facets use numpunct
. The numpunct<char>
and numpunct<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 grouping
, which calls do_grouping
. 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:
The following are the virtual, protected members of numpunct
:
virtual
char_type
do_decimal_point
( )
const
Returns the decimal point character, which is typically
'.
' in U.S. locales and
',
' in European locales. In
the "C
" locale, the decimal
point is '.
' or L'.
'.
virtual string_type
do_falsename
( )
const
Returns the textual representation for the value
false
. In the standard
instantiations (numpunct<char>
and numpunct<wchar_t>
), the value
is "false
" or L"false
".
virtual
string
do_grouping
( )
const
Returns a string that specifies the positions of
thousands separators. The string is interpreted as a vector of
integers, in which each value is a number of digits, starting
from the right. Thus, the string "\3
" means every three digits form a
group. In the "C
" locale,
the grouping is "" or L"
".
virtual
char_type
do_thousands_sep
( )
const
Returns the character used to separate digit groups.
(See do_grouping
earlier in
this section.) In U.S. locales, this is typically ',
', and in European locales, it is
typically '.
'. In the
"C
" locale, the thousands
separator is '\0
' or
L'\0
'.
virtual
string_type
do_truename
( )
const
Returns the textual representation for the value
true
. In the standard
instantiations (numpunct<char>
and numpunct<wchar_t>
), the value
is "true
" or L"true
".