Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::numpunct<CharT>::thousands_sep, do_thousands_sep

      From cppreference.com
      <cpp‎ |locale‎ |numpunct
       
       
       
      Localization library
       
       
      Defined in header<locale>
      public:
      char_type thousands_sep()const;
      (1)
      protected:
      virtual char_type do_thousands_sep()const;
      (2)
      1) Public member function, calls the member functiondo_thousands_sep of the most derived class.
      2) Returns the character to be used as the separator between digit groups when parsing or formatting integers and integral parts of floating-point values.

      Contents

      [edit]Return value

      The object of typechar_type to use as the thousands separator. The standard specializations ofstd::numpunct return',' andL','.

      [edit]Example

      Run this code
      #include <iostream>#include <locale> struct space_out:std::numpunct<char>{char do_thousands_sep()const{return' ';}// separate with spacesstd::string do_grouping()const{return"\1";}// groups of 1 digit}; int main(){std::cout<<"default locale: "<<12345678<<'\n';std::cout.imbue(std::locale(std::cout.getloc(), new space_out));std::cout<<"locale with modified numpunct: "<<12345678<<'\n';}

      Output:

      default locale: 12345678locale with modified numpunct: 1 2 3 4 5 6 7 8

      [edit]Defect reports

      The following behavior-changing defect reports were applied retroactively to previously published C++ standards.

      DRApplied toBehavior as publishedCorrect behavior
      LWG 20C++98the return type wasstring_typechanged tochar_type

      [edit]See also

      [virtual]
      provides the numbers of digits between each pair of thousands separators
      (virtual protected member function)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/locale/numpunct/thousands_sep&oldid=141820"

      [8]ページ先頭

      ©2009-2026 Movatter.jp