---
name: "std::moneypunct"
section: "3"
platform: "linux"
package: "gcc"
version: "16.2.1+r23+gd564253eb6c8-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/std::moneypunct"
---

# std::moneypunct(3)

Primary class template moneypunct.

## NAME

std::moneypunct\< \_CharT, \_Intl \> - Primary class template moneypunct.

## 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\_type**\
 enum **part** { **none**, **space**, **symbol**, **sign**, **value** }\

typedef \_CharT **char\_type**\
 Public typedefs.  typedef **basic\_string**\< \_CharT \> **string\_type**\
 Public typedefs.

### Public Member Functions

**moneypunct** (\_\_c\_locale \_\_cloc, const char \*\_\_s, size\_t \_\_refs=0)\
 Internal constructor. Not for general use.  **moneypunct** (\_\_cache\_type \*\_\_cache, size\_t \_\_refs=0)\
 Constructor performs initialization.  **moneypunct** (size\_t \_\_refs=0)\
 Constructor performs initialization.  **string\_type** **curr\_symbol** () const\
 Return currency symbol string.  **char\_type** **decimal\_point** () const\
 Return decimal point character.  int **frac\_digits** () const\
 Return number of digits in fraction.  **string** **grouping** () const\
 Return grouping specification.  **string\_type** **negative\_sign** () const\
 Return negative sign string.  **string\_type** **positive\_sign** () const\
 Return positive sign string.  **char\_type** **thousands\_sep** () const\
 Return thousands separator character.

pattern **pos\_format** () const\
 Return pattern for money values.  pattern **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\_atoms**\
 static const pattern **\_S\_default\_pattern**\
 static **locale::id** **id**\
 Numpunct facet id.  static const bool **intl**\
 This value is provided by the standard, but no reason for its existence.

### Protected Member Functions

virtual **~moneypunct** ()\
 Destructor.  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 string.  virtual **char\_type** **do\_decimal\_point** () const\
 Return decimal point character.  virtual int **do\_frac\_digits** () const\
 Return number of digits in fraction.  virtual **string** **do\_grouping** () const\
 Return grouping specification.  virtual pattern **do\_neg\_format** () const\
 Return pattern for money values.  virtual **string\_type** **do\_negative\_sign** () const\
 Return negative sign string.  virtual pattern **do\_pos\_format** () const\
 Return pattern for money values.  virtual **string\_type** **do\_positive\_sign** () const\
 Return positive sign string.  virtual **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.

## 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.

## 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.

**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 is an internal constructor.

**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.

**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.

## Member Function Documentation

### template\<typename \_CharT, bool \_Intl\> string\_type std::moneypunct\< \_CharT, \_Intl \>::curr\_symbol () const \[inline\]

Return currency symbol string. This function returns a string\_type to use as a currency symbol. It does so by returning returning moneypunct\<char\_type\>::do\_curr\_symbol().

**Returns**

*string\_type* representing 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 returns a char\_type to use as a decimal point. It does so by returning returning moneypunct\<char\_type\>::do\_decimal\_point().

**Returns**

*char\_type* representing 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 returns a string\_type to use as a currency symbol. This function is a hook for derived classes to change the value returned.

**See also**

curr\_symbol() for details.

**Returns**

*string\_type* representing 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\_type* representing 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\_type* representing 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\_type* representing 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\_type* representing 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 so by returning 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.

**Returns**

Number of digits in amount fraction.

References **do\_frac\_digits()**.

### template\<typename \_CharT, bool \_Intl\> string std::moneypunct\< \_CharT, \_Intl \>::grouping () const \[inline\]

Return grouping specification. This function returns a string representing groupings for the integer part of an amount. Groupings indicate where thousands separators should be inserted.

Each char in the return string is interpret as an integer rather than a character. These 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.

For example, if the grouping() returns \\003\\002 and is applied to the number 123456789, this corresponds to 12,34,56,789. 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.

The string is returned by calling moneypunct\<char\_type\>::do\_grouping().

**Returns**

string representing grouping specification.

References **do\_grouping()**.

### template\<typename \_CharT, bool \_Intl\> pattern std::moneypunct\< \_CharT, \_Intl \>::neg\_format () const \[inline\]

Return pattern for money values. This function returns a pattern describing the formatting of a positive or negative valued money amount. It does so by returning returning moneypunct\<char\_type\>::do\_pos\_format() or moneypunct\<char\_type\>::do\_neg\_format().

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\_neg\_format()**.

### 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 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.

**Returns**

*string\_type* representing a negative sign.

References **do\_negative\_sign()**.

### template\<typename \_CharT, bool \_Intl\> pattern std::moneypunct\< \_CharT, \_Intl \>::pos\_format () const \[inline\]

Return pattern for money values. This function returns a pattern describing the formatting of a positive or negative valued money amount. It does so by returning returning moneypunct\<char\_type\>::do\_pos\_format() or moneypunct\<char\_type\>::do\_neg\_format().

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()**.

### 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 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()**.

### 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 returning moneypunct\<char\_type\>::do\_thousands\_sep().

**Returns**

char\_type representing a thousands separator.

References **do\_thousands\_sep()**.

## Member Data Documentation

### template\<typename \_CharT, bool \_Intl\> locale::id std::moneypunct\< \_CharT, \_Intl \>::id \[static\]

Numpunct facet id.

### 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.

## Author

Generated automatically by Doxygen for libstdc++ from the source code.
