Difference between revisions of "cpp/locale/numpunct"
From cppreference.com
(fmt) |
m (r2.7.3) (Robot: Adding de, es, fr, it, ja, pt, ru, zh) |
||
Line 84: | Line 84: | ||
{{dcl list tclass | cpp/locale/numpunct_byname | creates a numpunct facet for the named locale }} | {{dcl list tclass | cpp/locale/numpunct_byname | creates a numpunct facet for the named locale }} | ||
{{dcl list end}} | {{dcl list end}} | ||
+ | |||
+ | [[de:cpp/locale/numpunct]] | ||
+ | [[es:cpp/locale/numpunct]] | ||
+ | [[fr:cpp/locale/numpunct]] | ||
+ | [[it:cpp/locale/numpunct]] | ||
+ | [[ja:cpp/locale/numpunct]] | ||
+ | [[pt:cpp/locale/numpunct]] | ||
+ | [[ru:cpp/locale/numpunct]] | ||
+ | [[zh:cpp/locale/numpunct]] |
Revision as of 18:04, 2 November 2012
Template:ddcl list begin <tr class="t-dsc-header">
<td>Defined in header
</td>
<locale>
<td></td> <td></td> </tr> <tr class="t-dcl ">
<td class="t-dcl-nopad">template< class CharT >
class numpunct;
</td>
class numpunct;
<td class="t-dcl-nopad"> </td> <td class="t-dcl-nopad"> </td> </tr> Template:ddcl list end
The facet std::numpunct encapsulates numeric punctuation preferences. Stream I/O operations use std::numpunct through std::num_get and std::num_put for parsing numeric input and formatting numeric output.
Inheritance diagram
Two specializations are provided by the standard library
Defined in header
<locale> | |
std::numpunct<char> | provides equivalents of the "C" locale preferences |
std::numpunct<wchar_t> | provides wide character equivalents of the "C" locale preferences |
Contents |
Member types
Member type | Definition |
char_type
|
charT
|
string_type
|
std::basic_string<charT> |
Member functions
Protected member functions
Member objects
static std::locale::id id |
id of the locale (public member object) |
Example
The following example changes the string representations of true and false
Run this code
#include <iostream> #include <locale> struct french_bool : std::numpunct<char> { string_type do_truename() const { return "oui"; } string_type do_falsename() const { return "non"; } }; int main() { std::cout << "default locale: " << std::boolalpha << true << ", " << false << '\n'; std::cout.imbue(std::locale(std::cout.getloc(), new french_bool())); std::cout << "locale with modified numpunct: " << std::boolalpha << true << ", " << false << '\n'; }
Output:
default locale: true, false locale with modified numpunct: oui, non
See also
creates a numpunct facet for the named locale (class template) |