std::moneypunct_byname
From cppreference.com
C++
Feature test macros (C++20)
Concepts library (C++20)
Metaprogramming library (C++11)
Ranges library (C++20)
Filesystem library (C++17)
Concurrency support library (C++11)
Execution control library (C++26)
Text processing library
Regular expressions library (C++11)
Formatting library (C++20)
(C++17)
(C++17)
(C++17)
(C++17)
(C++17)
(C++26)
Localization library
moneypunct_byname
(C++11/17/26*)
(C++11/17/26*)
(C++11/17/26*)
(C++11/17/26*)
(C++11/17/26*)
(C++11/17/26*)
Defined in header
<locale>
template< class CharT, bool Intl = false >
class moneypunct_byname : public std::moneypunct <CharT, Intl>;
class moneypunct_byname : public std::moneypunct <CharT, Intl>;
std::moneypunct_byname
is a std::moneypunct facet which encapsulates monetary formatting preferences of a locale specified at its construction.
Contents
[edit] Specializations
The standard library is guaranteed to provide every specialization that satisfies the following type requirements:
-
CharT
is one of char and wchar_t, and -
Intl
is a possible specialization on a bool parameter.
[edit] Nested types
Type
Definition
pattern
std::money_base::pattern
string_type
std::basic_string <CharT>
[edit] Member functions
std::moneypunct_byname::moneypunct_byname
explicit moneypunct_byname( const char* name, std::size_t refs = 0 );
explicit moneypunct_byname( const std::string & name, std::size_t refs = 0 );
(since C++11)
Constructs a new std::moneypunct_byname
facet for a locale with name.
refs is used for resource management: if refs == 0, the implementation destroys the facet, when the last std::locale object holding it is destroyed. Otherwise, the object is not destroyed.
Parameters
name
-
the name of the locale
refs
-
the number of references that link to the facet
std::moneypunct_byname::~moneypunct_byname
protected:
~moneypunct_byname();
~moneypunct_byname();
Destroys the facet.
Inherited from std::moneypunct
Nested types
Type
Definition
char_type
CharT
string_type
std::basic_string <CharT>
Data members
Member
Description
const bool
intl
[static]
International
Member functions
invokes
(public member function of
do_positive_sign
or do_negative_sign
(public member function of
std::moneypunct<CharT,International>
) [edit]
invokes
(public member function of
do_pos_format
/do_neg_format
(public member function of
std::moneypunct<CharT,International>
) [edit]
Protected member functions
[virtual]
(virtual protected member function of
std::moneypunct<CharT,International>
) [edit]
[virtual]
(virtual protected member function of
std::moneypunct<CharT,International>
) [edit]
[virtual]
(virtual protected member function of
std::moneypunct<CharT,International>
) [edit]
[virtual]
(virtual protected member function of
std::moneypunct<CharT,International>
) [edit]
[virtual]
(virtual protected member function of
std::moneypunct<CharT,International>
) [edit]
[virtual]
(virtual protected member function of
std::moneypunct<CharT,International>
) [edit]
[virtual]
(virtual protected member function of
std::moneypunct<CharT,International>
) [edit]
Inherited from std::money_base
Nested types
Type
Definition
enum part { none, space, symbol, sign, value };
unscoped enumeration type
struct pattern { char field[4]; };
the monetary format type
Enumeration constant
Description
none
whitespace is permitted but not required except in the last position, where whitespace is not permitted
space
one or more whitespace characters are required
symbol
the sequence of characters returned by std::moneypunct::curr_symbol is required
sign
the first of the characters returned by std::moneypunct::positive_sign or std::moneypunct::negative_sign is required
value
the absolute numeric monetary value is required
[edit] Example
This example demonstrates how to apply monetary formatting rules of another language without changing the rest of the locale.
Run this code
#include <iomanip> #include <iostream> #include <locale> int main() { long double mon = 1234567; std::locale::global (std::locale ("en_US.utf8")); std::wcout.imbue(std::locale ()); std::wcout << L"american locale: " << std::showbase << std::put_money (mon) << '\n'; std::wcout.imbue(std::locale (std::wcout.getloc(), new std::moneypunct_byname<wchar_t>("ru_RU.utf8"))); std::wcout << L"american locale with russian moneypunct: " << std::put_money (mon) << '\n'; }
Output:
american locale: 12,345ドル.67 american locale with russian moneypunct: 12 345.67 руб
[edit] See also
defines monetary formatting parameters used by std::money_get and std::money_put
(class template) [edit]
(class template) [edit]