Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::numpunct_byname

      From cppreference.com
      <cpp‎ |locale
       
       
       
      Localization library
       
      Defined in header<locale>
      template<class CharT>
      class numpunct_byname:publicstd::numpunct<CharT>;

      std::numpunct_byname is astd::numpunct facet which encapsulates numeric punctuation preferences of a locale specified at its construction.

      Contents

      [edit]Specializations

      The standard library is guaranteed to provide the following specializations:

      Defined in header<locale>
      std::numpunct_byname<char> locale-specificstd::numpunct facet for narrow character I/O
      std::numpunct_byname<wchar_t> locale-specificstd::numpunct facet for wide character I/O

      [edit]Nested types

      Type Definition
      char_typeCharT
      string_typestd::basic_string<CharT>

      [edit]Member functions

      (constructor)
      constructs a newnumpunct_byname facet
      (public member function)[edit]
      (destructor)
      destroys anumpunct_byname facet
      (protected member function)[edit]
      [edit]

      std::numpunct_byname::numpunct_byname

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

      Constructs a newstd::numpunct_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::numpunct_byname::~numpunct_byname

      protected:
      ~numpunct_byname();

      Destroys the facet.

      [edit]

      Inherited fromstd::numpunct

      Nested types

      Type Definition
      char_typeCharT
      string_typestd::basic_string<CharT>

      [edit]Data members

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

      Member functions

      invokesdo_decimal_point
      (public member function ofstd::numpunct<CharT>)[edit]
      invokesdo_thousands_sep
      (public member function ofstd::numpunct<CharT>)[edit]
      invokesdo_grouping
      (public member function ofstd::numpunct<CharT>)[edit]
      invokesdo_truename ordo_falsename
      (public member function ofstd::numpunct<CharT>)[edit]

      Protected member functions

      provides the character to use as decimal point
      (virtual protected member function ofstd::numpunct<CharT>)[edit]
      provides the character to use as thousands separator
      (virtual protected member function ofstd::numpunct<CharT>)[edit]
      [virtual]
      provides the numbers of digits between each pair of thousands separators
      (virtual protected member function ofstd::numpunct<CharT>)[edit]
      provides the string to use as the name of the booleantrue andfalse
      (virtual protected member function ofstd::numpunct<CharT>)[edit]

      [edit]Example

      This example demonstrates how to apply numeric punctuation rules of another language without changing the rest of the locale.

      Run this code
      #include <iostream>#include <locale> int main(){constdouble number=1000.25;std::wcout<< L"default locale: "<< number<< L'\n';std::wcout.imbue(std::locale(std::wcout.getloc(),                                 new std::numpunct_byname<wchar_t>("ru_RU.UTF8")));std::wcout<< L"default locale with russian numpunct: "<< number<< L'\n';}

      Output:

      default locale: 1000.25default locale with russian numpunct: 1 000,25

      [edit]See also

      defines numeric punctuation rules
      (class template)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/locale/numpunct_byname&oldid=177753"

      [8]ページ先頭

      ©2009-2025 Movatter.jp