STD::MONEYPUNCT(3)
std::moneypunct< _CharT, _Intl > πΈβ¨
okay bestie, welcome to the moneypunct page β it lives in Library Functions Manual and it is the primary class template for money punctuation. yes, that's the whole vibe. money. punctuation. iconique.
β¨ NAME β¨
std::moneypunct< _CharT, _Intl > β the primary class template moneypunct, no cap π
πΈ SYNOPSIS πΈ
#include <locale>
Inherits std::locale::facet, and std::money_base.
Inherited by std::moneypunct_byname< _CharT, _Intl >.
π«Ά Public Types
enum { _S_minus, _S_zero, _S_end }typedef __moneypunct_cache< _CharT, _Intl > __cache_typeenum part { none, space, symbol, sign, value }typedef _CharT char_typeβ public typedefs, slaytypedef basic_string< _CharT > string_typeβ public typedefs, also slay
π Public Member Functions
moneypunct (__c_locale __cloc, const char *__s, size_t __refs=0)β internal constructor, not for general use. it's for the library's own self to set up new locales π§moneypunct (__cache_type *__cache, size_t __refs=0)β constructor performs initializationmoneypunct (size_t __refs=0)β constructor performs initializationstring_type curr_symbol () constβ return currency symbol stringchar_type decimal_point () constβ return decimal point characterint frac_digits () constβ return number of digits in fractionstring grouping () constβ return grouping specificationstring_type negative_sign () constβ return negative sign stringstring_type positive_sign () constβ return positive sign stringchar_type thousands_sep () constβ return thousands separator characterpattern pos_format () constβ return pattern for money valuespattern neg_format () constβ return pattern for money values
π Static Public Member Functions
static pattern _S_construct_pattern (char __precedes, char __space, char __posn) throw ()
π¦ Static Public Attributes
static const char * _S_atomsstatic const pattern _S_default_patternstatic locale::id idβ the numpunct facet idstatic const bool intlβ this value is provided by the standard, but there's genuinely no reason for its existence π
π Protected Member Functions
virtual ~moneypunct ()β destructor, bye bestie πvoid _M_initialize_moneypunct (__c_locale __cloc=0, const char *__name=0)void _M_initialize_moneypunct (__c_locale, const char *)void _M_initialize_moneypunct (__c_locale, const char *)void _M_initialize_moneypunct (__c_locale, const char *)void _M_initialize_moneypunct (__c_locale, const char *)virtual string_type do_curr_symbol () constβ return currency symbol stringvirtual char_type do_decimal_point () constβ return decimal point charactervirtual int do_frac_digits () constβ return number of digits in fractionvirtual string do_grouping () constβ return grouping specificationvirtual pattern do_neg_format () constβ return pattern for money valuesvirtual string_type do_negative_sign () constβ return negative sign stringvirtual pattern do_pos_format () constβ return pattern for money valuesvirtual string_type do_positive_sign () constβ return positive sign stringvirtual char_type do_thousands_sep () constβ return thousands separator character
π§ Static Protected Member Functions
static __c_locale _S_clone_c_locale (__c_locale &__cloc) throw ()static void _S_create_c_locale (__c_locale &__cloc, const char *__s, __c_locale __old=0)static void _S_destroy_c_locale (__c_locale &__cloc)static __c_locale _S_get_c_locale ()static const char * _S_get_c_name () throw ()static __c_locale _S_lc_ctype_c_locale (__c_locale __cloc, const char *__s)
π Detailed Description π
template<typename _CharT, bool _Intl>
class std::moneypunct< _CharT, _Intl >
Primary class template moneypunct.
This facet encapsulates the punctuation, grouping and other formatting features of money amount string representations. it's literally the glow-up your currency strings go through before anyone sees them πΈβ¨
β Member Typedef Documentation β
template<typename _CharT, bool _Intl> typedef _CharT std::moneypunct<
_CharT, _Intl >::char_type
Public typedefs.
template<typename _CharT, bool _Intl> typedef basic_string<_CharT>
std::moneypunct< _CharT, _Intl >::string_type
Public typedefs. (yes it says it twice, that's the original energy, we respect it π«‘)
πΈ Constructor & Destructor Documentation πΈ
template<typename _CharT, bool _Intl> std::moneypunct< _CharT, _Intl
>::moneypunct (size_t __refs = 0) [inline], [explicit]
Constructor performs initialization. this is the constructor provided by the standard, so it's basically the main character ππ
Parameters:
__refsβ passed to the base facet class
References std::locale::facet::facet().
template<typename _CharT, bool _Intl> std::moneypunct< _CharT, _Intl
>::moneypunct (__cache_type * __cache, size_t __refs = 0) [inline],
[explicit]
Constructor performs initialization. this one is an internal constructor, so don't come for it π
Parameters:
__cacheβ cache for optimization__refsβ passed to the base facet class
References std::locale::facet::facet().
template<typename _CharT, bool _Intl> std::moneypunct< _CharT, _Intl
>::moneypunct (__c_locale __cloc, const char * __s, size_t __refs = 0)
[inline], [explicit]
Internal constructor. Not for general use. this is a constructor for use by the library itself to set up new locales β like, it's backstage only, no VIP pass for you bestie π
Parameters:
__clocβ the C locale__sβ the name of a locale__refsβ passed to the base facet class
References std::locale::facet::facet().
template<typename _CharT, bool _Intl> virtual std::moneypunct< _CharT, _Intl
>::~moneypunct () [protected], [virtual]
Destructor. it's giving closure, it's giving goodbye π₯Ήπ
π Member Function Documentation π
template<typename _CharT, bool _Intl> string_type std::moneypunct< _CharT,
_Intl >::curr_symbol () const [inline]
Return currency symbol string. this function hands back a string_type to use as a currency symbol, and the way it does that is by returning moneypunct<char_type>::do_curr_symbol().
Returns:
string_typerepresenting a currency symbol
References do_curr_symbol().
template<typename _CharT, bool _Intl> char_type std::moneypunct< _CharT,
_Intl >::decimal_point () const [inline]
Return decimal point character. this function hands back a char_type to use as a decimal point, and it does that by returning moneypunct<char_type>::do_decimal_point().
Returns:
char_typerepresenting a decimal point
References do_decimal_point().
template<typename _CharT, bool _Intl> virtual string_type std::moneypunct<
_CharT, _Intl >::do_curr_symbol () const [inline], [protected],
[virtual]
Return currency symbol string. this function hands back a string_type to use as a currency symbol. it's a hook for derived classes to change the value returned π§β¨
See also curr_symbol() for details.
Returns:
string_typerepresenting a currency symbol
Referenced by curr_symbol().
template<typename _CharT, bool _Intl> virtual char_type std::moneypunct<
_CharT, _Intl >::do_decimal_point () const [inline], [protected],
[virtual]
Return decimal point character. returns a char_type to use as a decimal point. this function is a hook for derived classes to change the value returned.
Returns:
char_typerepresenting a decimal point
Referenced by decimal_point().
template<typename _CharT, bool _Intl> virtual int std::moneypunct< _CharT,
_Intl >::do_frac_digits () const [inline], [protected], [virtual]
Return number of digits in fraction. this function returns the exact number of digits that make up the fractional part of a money amount. this function is a hook for derived classes to change the value returned.
See also frac_digits() for details.
Returns:
- number of digits in amount fraction
Referenced by frac_digits().
template<typename _CharT, bool _Intl> virtual string std::moneypunct<
_CharT, _Intl >::do_grouping () const [inline], [protected], [virtual]
Return grouping specification. returns a string representing groupings for the integer part of a number. this function is a hook for derived classes to change the value returned.
See also grouping() for details.
Returns:
- string representing grouping specification
Referenced by grouping().
template<typename _CharT, bool _Intl> virtual pattern std::moneypunct<
_CharT, _Intl >::do_neg_format () const [inline], [protected],
[virtual]
Return pattern for money values. this function returns a pattern describing the formatting of a negative valued money amount. this function is a hook for derived classes to change the value returned.
See also neg_format() for details.
Returns:
- pattern for money values
Referenced by neg_format().
template<typename _CharT, bool _Intl> virtual string_type std::moneypunct<
_CharT, _Intl >::do_negative_sign () const [inline], [protected],
[virtual]
Return negative sign string. this function returns a string_type to use as a sign for negative amounts. this function is a hook for derived classes to change the value returned.
See also negative_sign() for details.
Returns:
string_typerepresenting a negative sign
Referenced by negative_sign().
template<typename _CharT, bool _Intl> virtual pattern std::moneypunct<
_CharT, _Intl >::do_pos_format () const [inline], [protected],
[virtual]
Return pattern for money values. this function returns a pattern describing the formatting of a positive valued money amount. this function is a hook for derived classes to change the value returned.
See also pos_format() for details.
Returns:
- pattern for money values
Referenced by pos_format().
template<typename _CharT, bool _Intl> virtual string_type std::moneypunct<
_CharT, _Intl >::do_positive_sign () const [inline], [protected],
[virtual]
Return positive sign string. this function returns a string_type to use as a sign for positive amounts. this function is a hook for derived classes to change the value returned.
See also positive_sign() for details.
Returns:
string_typerepresenting a positive sign
Referenced by positive_sign().
template<typename _CharT, bool _Intl> virtual char_type std::moneypunct<
_CharT, _Intl >::do_thousands_sep () const [inline], [protected],
[virtual]
Return thousands separator character. returns a char_type to use as a thousands separator. this function is a hook for derived classes to change the value returned.
Returns:
char_typerepresenting a thousands separator
Referenced by thousands_sep().
template<typename _CharT, bool _Intl> int std::moneypunct< _CharT, _Intl
>::frac_digits () const [inline]
Return number of digits in fraction. this function returns the exact number of digits that make up the fractional part of a money amount. it does that by returning moneypunct<char_type>::do_frac_digits().
the fractional part of a money amount is optional. but if it is present, there must be frac_digits() digits β that's the rule, no negotiating π₯
Returns:
- number of digits in amount fraction
References do_frac_digits().
grouping() β where the commas go π
template<typename _CharT, bool _Intl> string std::moneypunct< _CharT, _Intl
>::grouping () const [inline]
Okay bestie, this one returns the grouping specification. It's a string that tells the integer part of an amount how to group digits, aka where the thousands separators should be inserted. Iconic.
Each char in the return string is interpreted as an integer rather than a character. Those numbers represent the number of digits in a group. The first char in the string represents the number of digits in the least significant group. If a char is negative, it indicates an unlimited number of digits for the group. If more chars from the string are required to group a number, the last char is used repeatedly. She's reusing her last note like a true main character.
For example, if grouping() returns \003\002 and is applied to the number 123456789, this corresponds to 12,34,56,789. Not me doing math in public. Note that if the string was 32, this would put more than 50 digits into the least significant group if the character set is ASCII. Lowkey unhinged, but okay.
The string is returned by calling moneypunct<char_type>::do_grouping().
Returns
string representing grouping specification.
References
do_grouping().
neg_format() β the pattern for negative (and positive) money vibes π
template<typename _CharT, bool _Intl> pattern std::moneypunct< _CharT, _Intl
>::neg_format () const [inline]
This function returns a pattern describing the formatting of a positive or negative valued money amount. It does so by returning moneypunct<char_type>::do_pos_format() or moneypunct<char_type>::do_neg_format(). Yes bestie, both are mentioned β it's giving flexible.
The pattern has 4 fields describing the ordering of symbol, sign, value, and none or space. There must be one of each in the pattern. The none and space enums may not appear in the first field, and space may not appear in the final field. Periodt, those are the rules.
The parts of a money string must appear in the order indicated by the fields of the pattern. The symbol field indicates that the value of curr_symbol() may be present. The sign field indicates that the value of positive_sign() or negative_sign() must be present. The value field indicates that the absolute value of the money amount is present. none indicates 0 or more whitespace characters, except at the end, where it permits no whitespace. space indicates that 1 or more whitespace characters must be present.
For example, for the US locale and pos_format() pattern {symbol,sign,value,none}, curr_symbol() == '$', positive_sign() == '+', and value 10.01, and options set to force the symbol, the corresponding string is $+10.01. She's expensive, your honor.
Returns
Pattern for money values.
References
do_neg_format().
negative_sign() β the minus sign, but make it fashion π
template<typename _CharT, bool _Intl> string_type std::moneypunct< _CharT,
_Intl >::negative_sign () const [inline]
Return negative sign string. This function returns a string_type to use as a sign for negative amounts. It does so by returning moneypunct<char_type>::do_negative_sign().
If the return value contains more than one character, the first character appears in the position indicated by neg_format() and the remainder appear at the end of the formatted string. Multi-character negativity? She's dramatic.
Returns
string_type representing a negative sign.
References
do_negative_sign().
pos_format() β pattern for money values, positive edition β¨
template<typename _CharT, bool _Intl> pattern std::moneypunct< _CharT, _Intl
>::pos_format () const [inline]
This function returns a pattern describing the formatting of a positive or negative valued money amount. It does so by returning moneypunct<char_type>::do_pos_format() or moneypunct<char_type>::do_neg_format(). Same energy as neg_format(), different reference.
The pattern has 4 fields describing the ordering of symbol, sign, value, and none or space. There must be one of each in the pattern. The none and space enums may not appear in the first field, and space may not appear in the final field.
The parts of a money string must appear in the order indicated by the fields of the pattern. The symbol field indicates that the value of curr_symbol() may be present. The sign field indicates that the value of positive_sign() or negative_sign() must be present. The value field indicates that the absolute value of the money amount is present. none indicates 0 or more whitespace characters, except at the end, where it permits no whitespace. space indicates that 1 or more whitespace characters must be present.
For example, for the US locale and pos_format() pattern {symbol,sign,value,none}, curr_symbol() == '$', positive_sign() == '+', and value 10.01, and options set to force the symbol, the corresponding string is $+10.01.
Returns
Pattern for money values.
References
do_pos_format().
positive_sign() β plus sign, but cute π
template<typename _CharT, bool _Intl> string_type std::moneypunct< _CharT,
_Intl >::positive_sign () const [inline]
Return positive sign string. This function returns a string_type to use as a sign for positive amounts. It does so by returning moneypunct<char_type>::do_positive_sign().
If the return value contains more than one character, the first character appears in the position indicated by pos_format() and the remainder appear at the end of the formatted string.
Returns
string_type representing a positive sign.
References
do_positive_sign().
thousands_sep() β the comma's origin story π¦
template<typename _CharT, bool _Intl> char_type std::moneypunct< _CharT,
_Intl >::thousands_sep () const [inline]
Return thousands separator character. This function returns a char_type to use as a thousands separator. It does so by returning moneypunct<char_type>::do_thousands_sep().
Returns
char_type representing a thousands separator.
References
do_thousands_sep().
π Member Data Documentation π
id β the facet id, no cap π
template<typename _CharT, bool _Intl> locale::id std::moneypunct< _CharT,
_Intl >::id [static]
Numpunct facet id. Yes bestie, it says numpunct β we're keeping it exactly as the page does.
intl β provided by the standard, reason unknown π
template<typename _CharT, bool _Intl> const bool std::moneypunct< _CharT,
_Intl >::intl [static]
This value is provided by the standard, but no reason for its existence. Not the standard exposing its lore and not explaining it. We love a mysterious static bool.
π«Ά Author π«Ά
Generated automatically by Doxygen for libstdc++ from the source code.
That's the whole vibe. This page is fromlibstdc++β source/versionlibstdc++, pagestd::money...T, _Intl >(3)β and it's dated whenever this Doxygen build was generated. Bye bestie, go format some money. πΈβ¨
π¦ where this page comes from
- arch rolling: gcc 16.2.1+r23+gd564253eb6c8-1 Β· GPL-3.0-or-later WITH GCC-exception-3.1 AND GFDL-1.3-or-later
- centos-stream 10: gcc-toolset-15-libstdc++-docs 15.2.1-8.1.el10 Β· GPL-3.0-or-later AND LGPL-3.0-or-later AND (GPL-3.0-or-later WITH GCC-exception-3.1) AND (GPL-3.0-or-later WITH Texinfo-exception) AND (LGPL-2.1-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GNU-compiler-exception) AND BSL-1.0 AND GFDL-1.3-or-later AND Linux-man-pages-copyleft-2-para AND SunPro AND BSD-1-Clause AND BSD-2-Clause AND BSD-2-Clause-Views AND BSD-3-Clause AND BSD-4-Clause AND BSD-Source-Code AND Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 WITH LLVM-Exception) AND ZPL-2.1 AND ISC AND LicenseRef-Fedora-Public-Domain AND HP-1986 AND curl AND Martin-Birgmeier AND HPND-Markus-Kuhn AND dtoa AND SMLNJ AND AMD-newlib AND OAR AND HPND-merchantability-variant AND HPND-Intel
- centos-stream 10: gcc-toolset-16-libstdc++-docs 16.2.1-1.3.el10 Β· GPL-3.0-or-later AND LGPL-3.0-or-later AND (GPL-3.0-or-later WITH GCC-exception-3.1) AND (GPL-3.0-or-later WITH Texinfo-exception) AND (LGPL-2.1-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GNU-compiler-exception) AND BSL-1.0 AND GFDL-1.3-or-later AND Linux-man-pages-copyleft-2-para AND SunPro AND BSD-1-Clause AND BSD-2-Clause AND BSD-2-Clause-Views AND BSD-3-Clause AND BSD-4-Clause AND BSD-Source-Code AND Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 WITH LLVM-Exception) AND ZPL-2.1 AND ISC AND LicenseRef-Fedora-Public-Domain AND HP-1986 AND curl AND Martin-Birgmeier AND HPND-Markus-Kuhn AND dtoa AND SMLNJ AND AMD-newlib AND OAR AND HPND-merchantability-variant AND HPND-Intel
- centos-stream 10: libstdc++-docs 14.4.1-4.el10 Β· GPL-3.0-or-later AND LGPL-3.0-or-later AND (GPL-3.0-or-later WITH GCC-exception-3.1) AND (GPL-3.0-or-later WITH Texinfo-exception) AND (LGPL-2.1-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GNU-compiler-exception) AND BSL-1.0 AND GFDL-1.3-or-later AND Linux-man-pages-copyleft-2-para AND SunPro AND BSD-1-Clause AND BSD-2-Clause AND BSD-2-Clause-Views AND BSD-3-Clause AND BSD-4-Clause AND BSD-Source-Code AND Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 WITH LLVM-Exception) AND ZPL-2.1 AND ISC AND LicenseRef-Fedora-Public-Domain AND HP-1986 AND curl AND Martin-Birgmeier AND HPND-Markus-Kuhn AND dtoa AND SMLNJ AND AMD-newlib AND OAR AND HPND-merchantability-variant AND HPND-Intel
- fedora 43: libstdc++-docs 15.2.1-2.fc43 Β· GPL-3.0-or-later AND LGPL-3.0-or-later AND (GPL-3.0-or-later WITH GCC-exception-3.1) AND (GPL-3.0-or-later WITH Texinfo-exception) AND (LGPL-2.1-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GNU-compiler-exception) AND BSL-1.0 AND GFDL-1.3-or-later AND Linux-man-pages-copyleft-2-para AND SunPro AND BSD-1-Clause AND BSD-2-Clause AND BSD-2-Clause-Views AND BSD-3-Clause AND BSD-4-Clause AND BSD-Source-Code AND Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 WITH LLVM-Exception) AND ZPL-2.1 AND ISC AND LicenseRef-Fedora-Public-Domain AND HP-1986 AND curl AND Martin-Birgmeier AND HPND-Markus-Kuhn AND dtoa AND SMLNJ AND AMD-newlib AND OAR AND HPND-merchantability-variant AND HPND-Intel
- fedora 43: libstdc++-docs 15.3.1-1.fc43 Β· GPL-3.0-or-later AND LGPL-3.0-or-later AND (GPL-3.0-or-later WITH GCC-exception-3.1) AND (GPL-3.0-or-later WITH Texinfo-exception) AND (LGPL-2.1-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GNU-compiler-exception) AND BSL-1.0 AND GFDL-1.3-or-later AND Linux-man-pages-copyleft-2-para AND SunPro AND BSD-1-Clause AND BSD-2-Clause AND BSD-2-Clause-Views AND BSD-3-Clause AND BSD-4-Clause AND BSD-Source-Code AND Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 WITH LLVM-Exception) AND ZPL-2.1 AND ISC AND LicenseRef-Fedora-Public-Domain AND HP-1986 AND curl AND Martin-Birgmeier AND HPND-Markus-Kuhn AND dtoa AND SMLNJ AND AMD-newlib AND OAR AND HPND-merchantability-variant AND HPND-Intel
- fedora 44: libstdc++-docs 16.0.1-0.10.fc44 Β· GPL-3.0-or-later AND LGPL-3.0-or-later AND (GPL-3.0-or-later WITH GCC-exception-3.1) AND (GPL-3.0-or-later WITH Texinfo-exception) AND (LGPL-2.1-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GNU-compiler-exception) AND BSL-1.0 AND GFDL-1.3-or-later AND Linux-man-pages-copyleft-2-para AND SunPro AND BSD-1-Clause AND BSD-2-Clause AND BSD-2-Clause-Views AND BSD-3-Clause AND BSD-4-Clause AND BSD-Source-Code AND Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 WITH LLVM-Exception) AND ZPL-2.1 AND ISC AND LicenseRef-Fedora-Public-Domain AND HP-1986 AND curl AND Martin-Birgmeier AND HPND-Markus-Kuhn AND dtoa AND SMLNJ AND AMD-newlib AND OAR AND HPND-merchantability-variant AND HPND-Intel
- fedora 44: libstdc++-docs 16.2.1-2.fc44
- fedora 44: libstdc++-docs 16.2.1-3.fc44 Β· GPL-3.0-or-later AND LGPL-3.0-or-later AND (GPL-3.0-or-later WITH GCC-exception-3.1) AND (GPL-3.0-or-later WITH Texinfo-exception) AND (LGPL-2.1-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GNU-compiler-exception) AND BSL-1.0 AND GFDL-1.3-or-later AND Linux-man-pages-copyleft-2-para AND SunPro AND BSD-1-Clause AND BSD-2-Clause AND BSD-2-Clause-Views AND BSD-3-Clause AND BSD-4-Clause AND BSD-Source-Code AND Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 WITH LLVM-Exception) AND ZPL-2.1 AND ISC AND LicenseRef-Fedora-Public-Domain AND HP-1986 AND curl AND Martin-Birgmeier AND HPND-Markus-Kuhn AND dtoa AND SMLNJ AND AMD-newlib AND OAR AND HPND-merchantability-variant AND HPND-Intel
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms