Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::moneypunct_byname

      From cppreference.com
      <cpp‎ |locale
       
       
       
      Localization library
       
      Defined in header<locale>
      template<class CharT,bool Intl=false>
      class moneypunct_byname:publicstd::moneypunct<CharT, Intl>;

      std::moneypunct_byname is astd::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 ofchar andwchar_t, and
      • Intl is a possible specialization on abool parameter.

      [edit]Nested types

      Type Definition
      patternstd::money_base::pattern
      string_typestd::basic_string<CharT>

      [edit]Member functions

      (constructor)
      constructs a newmoneypunct_byname facet
      (public member function)[edit]
      (destructor)
      destroys amoneypunct_byname facet
      (protected member function)[edit]
      [edit]

      std::moneypunct_byname::moneypunct_byname

      explicit moneypunct_byname(constchar* name,std::size_t refs=0);
      explicit moneypunct_byname(conststd::string& name,std::size_t refs=0);
      (since C++11)

      Constructs a newstd::moneypunct_byname facet for a locale withname.

      refs is used for resource management: ifrefs==0, the implementation destroys the facet, when the laststd::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
      [edit]

      std::moneypunct_byname::~moneypunct_byname

      protected:
      ~moneypunct_byname();

      Destroys the facet.

      [edit]

      Inherited fromstd::moneypunct

      Nested types

      Type Definition
      char_typeCharT
      string_typestd::basic_string<CharT>

      Data members

      Member Description
      std::locale::idid[static] the identifier of thefacet
      constboolintl[static]International

      Member functions

      invokesdo_decimal_point
      (public member function ofstd::moneypunct<CharT,International>)[edit]
      invokesdo_thousands_sep
      (public member function ofstd::moneypunct<CharT,International>)[edit]
      invokesdo_grouping
      (public member function ofstd::moneypunct<CharT,International>)[edit]
      invokesdo_curr_symbol
      (public member function ofstd::moneypunct<CharT,International>)[edit]
      invokesdo_positive_sign ordo_negative_sign
      (public member function ofstd::moneypunct<CharT,International>)[edit]
      invokesdo_frac_digits
      (public member function ofstd::moneypunct<CharT,International>)[edit]
      invokesdo_pos_format/do_neg_format
      (public member function ofstd::moneypunct<CharT,International>)[edit]

      Protected member functions

      provides the character to use as decimal point
      (virtual protected member function ofstd::moneypunct<CharT,International>)[edit]
      provides the character to use as thousands separator
      (virtual protected member function ofstd::moneypunct<CharT,International>)[edit]
      [virtual]
      provides the numbers of digits between each pair of thousands separators
      (virtual protected member function ofstd::moneypunct<CharT,International>)[edit]
      provides the string to use as the currency identifier
      (virtual protected member function ofstd::moneypunct<CharT,International>)[edit]
      provides the string to indicate a positive or negative value
      (virtual protected member function ofstd::moneypunct<CharT,International>)[edit]
      provides the number of digits to display after the decimal point
      (virtual protected member function ofstd::moneypunct<CharT,International>)[edit]
      provides the formatting pattern for currency values
      (virtual protected member function ofstd::moneypunct<CharT,International>)[edit]
      [edit]

      Inherited fromstd::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 bystd::moneypunct::curr_symbol is required
      sign the first of the characters returned bystd::moneypunct::positive_sign orstd::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(){longdouble 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.67american locale with russian moneypunct: 12 345.67 руб

      [edit]See also

      defines monetary formatting parameters used bystd::money_get andstd::money_put
      (class template)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/locale/moneypunct_byname&oldid=178037"

      [8]ページ先頭

      ©2009-2025 Movatter.jp