std::moneypunct<CharT,International>:: curr_symbol, do_curr_symbol
From cppreference.net
<
cpp
|
locale
|
moneypunct
C++
Text processing library
| 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 | |||||||||||||||||||||||||
|
|||||||||||||||||||||||||
Localization library
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
std::moneypunct
| Member functions | ||||
|
moneypunct::curr_symbol
moneypunct::do_curr_symbol
|
||||
|
Défini dans l'en-tête
<locale>
|
||
|
public
:
string_type curr_symbol ( ) const ; |
(1) | |
|
protected
:
virtual string_type do_curr_symbol ( ) const ; |
(2) | |
1)
Fonction membre publique, appelle la fonction membre
do_curr_symbol
de la classe la plus dérivée.
2)
Retourne la chaîne utilisée comme identifiant de devise par cette locale. Si
International
(le second paramètre template de
std::moneypunct
) est
false
, l'identifiant est généralement un caractère (large) unique, tel que
"¥"
ou
"$"
. Si
International
est
true
, l'identifiant est généralement une chaîne de quatre caractères contenant le code de devise à trois caractères
ISO 4217
suivi d'un espace (
"JPY "
ou
"USD "
).
Table des matières |
Valeur de retour
L'objet de type
string_type
contenant le symbole ou code de devise.
Exemple
Exécuter ce code
#include <iostream> #include <locale> void show_ccy(const char* locname) { std::locale loc(locname); std::cout << locname << " currency symbol is " << std::use_facet<std::moneypunct<char, true>>(loc).curr_symbol() << "or " << std::use_facet<std::moneypunct<char>>(loc).curr_symbol() << " for short\n"; } int main() { show_ccy("en_US.utf8"); show_ccy("ja_JP.utf8"); show_ccy("sv_SE.utf8"); show_ccy("ru_RU.utf8"); show_ccy("vi_VN.utf8"); }
Sortie :
en_US.utf8 currency symbol is USD or $ for short ja_JP.utf8 currency symbol is JPY or ¥ for short sv_SE.utf8 currency symbol is SEK or kr for short ru_RU.utf8 currency symbol is RUB or руб for short vi_VN.utf8 currency symbol is VND or ₫ for short
Rapports de défauts
Les rapports de défauts modifiant le comportement suivants ont été appliqués rétroactivement aux normes C++ précédemment publiées.
| DR | Appliqué à | Comportement publié | Comportement corrigé |
|---|---|---|---|
| LWG 666 | C++98 |
la longueur de la chaîne d'identifiant devait être
4
si
International
est
true
|
non requis |
Voir aussi
|
[virtual]
|
fournit le motif de formatage pour les valeurs monétaires
(fonction membre protégée virtuelle) |