| Localization library | |||||||||||||||||||||||||
| Regular expressions library(C++11) | |||||||||||||||||||||||||
| Formatting library(C++20) | |||||||||||||||||||||||||
| Null-terminated sequence utilities | |||||||||||||||||||||||||
| Byte strings | |||||||||||||||||||||||||
| Multibyte strings | |||||||||||||||||||||||||
| Wide strings | |||||||||||||||||||||||||
| Primitive numeric conversions | |||||||||||||||||||||||||
| |||||||||||||||||||||||||
| Text encoding identifications | |||||||||||||||||||||||||
| |||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Defined in header <locale> | ||
template<class CharT> class numpunct_byname:publicstd::numpunct<CharT>; | ||
std::numpunct_byname is astd::numpunct facet which encapsulates numeric punctuation preferences of a locale specified at its construction.
Contents |
The standard library is guaranteed to provide the following specializations:
Defined in header <locale> | |
| std::numpunct_byname<char> | locale-specificstd::numpunct facet for narrow character I/O |
| std::numpunct_byname<wchar_t> | locale-specificstd::numpunct facet for wide character I/O |
| Type | Definition |
char_type | CharT |
string_type | std::basic_string<CharT> |
(constructor) | constructs a newnumpunct_byname facet(public member function)[edit] |
(destructor) | destroys anumpunct_byname facet(protected member function)[edit] |
explicit numpunct_byname(constchar* name,std::size_t refs=0); | ||
explicit numpunct_byname(conststd::string& name,std::size_t refs=0); | (since C++11) | |
Constructs a newstd::numpunct_byname facet for a locale withname.
refs is used for resource management: ifrefs==0, the implementation destroys the facet, when the laststd::locale object holding it is destroyed. Otherwise, the object is not destroyed.
| name | - | the name of the locale |
| refs | - | the number of references that link to the facet |
protected: ~numpunct_byname(); | ||
Destroys the facet.
| Type | Definition |
char_type | CharT |
string_type | std::basic_string<CharT> |
| Member | Description |
std::locale::idid[static] | the identifier of thefacet |
invokesdo_decimal_point(public member function of std::numpunct<CharT>)[edit] | |
invokesdo_thousands_sep(public member function of std::numpunct<CharT>)[edit] | |
invokesdo_grouping(public member function of std::numpunct<CharT>)[edit] | |
invokesdo_truename ordo_falsename(public member function of std::numpunct<CharT>)[edit] |
[virtual] | provides the character to use as decimal point (virtual protected member function of std::numpunct<CharT>)[edit] |
[virtual] | provides the character to use as thousands separator (virtual protected member function of std::numpunct<CharT>)[edit] |
[virtual] | provides the numbers of digits between each pair of thousands separators (virtual protected member function of std::numpunct<CharT>)[edit] |
[virtual] | provides the string to use as the name of the booleantrue andfalse (virtual protected member function of std::numpunct<CharT>)[edit] |
This example demonstrates how to apply numeric punctuation rules of another language without changing the rest of the locale.
#include <iostream>#include <locale> int main(){constdouble number=1000.25;std::wcout<< L"default locale: "<< number<< L'\n';std::wcout.imbue(std::locale(std::wcout.getloc(), new std::numpunct_byname<wchar_t>("ru_RU.UTF8")));std::wcout<< L"default locale with russian numpunct: "<< number<< L'\n';}
Output:
default locale: 1000.25default locale with russian numpunct: 1 000,25
| defines numeric punctuation rules (class template)[edit] |