| 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 | |||||||||||||||||||||||||
| |||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Member functions | ||||
moneypunct::pos_formatmoneypunct::do_pos_formatmoneypunct::neg_formatmoneypunct::do_neg_format |
Defined in header <locale> | ||
public: pattern pos_format()const; | (1) | |
public: pattern neg_format()const; | (2) | |
protected: virtual pattern do_pos_format()const; | (3) | |
protected: virtual pattern do_neg_format()const; | (4) | |
do_pos_format of the most derived class.do_neg_format of the most derived class.The standard specializations ofstd::moneypunct return the pattern{symbol, sign, none, value}.
Contents |
The object of typestd::money_base::format describing the formatting used by this locale.
Whilestd::money_put usespos_format for formatting positive values and neg_format for formatting negative values,std::money_get usesneg_format for parsing all monetary values: it assumes thatneg_format is compatible withpos_format.
#include <iomanip>#include <iostream>#include <locale> struct my_punct:std::moneypunct_byname<char,false>{ my_punct(constchar* name): moneypunct_byname(name){} pattern do_pos_format()const{return{value, space, symbol, sign};} pattern do_neg_format()const{return{value, space, symbol, sign};}}; int main(){std::cout.imbue(std::locale("en_US.utf8"));std::cout<<"american locale: "<<std::showbase<<std::put_money(12345678.0)<<'\n'; std::cout.imbue(std::locale(std::cout.getloc(), new my_punct("en_US.utf8")));std::cout<<"locale with modified moneypunct:\n"<<std::put_money(12345678.0)<<'\n'<<std::put_money(-12345678.0)<<'\n';}
Output:
american locale: $123,456.78locale with modified moneypunct:123,456.78 $123,456.78 $-
[virtual] | provides the string to use as the currency identifier (virtual protected member function)[edit] |
[virtual] | provides the string to indicate a positive or negative value (virtual protected member function)[edit] |
[virtual] | parses a monetary value from an input stream (virtual protected member function of std::money_get<CharT,InputIt>)[edit] |
[virtual] | formats a monetary value and writes to output stream (virtual protected member function of std::money_put<CharT,OutputIt>)[edit] |