• Class / Function / Type

      std::
    • Header file

      <>
    • Other / All

    最終更新日時(UTC):
    が更新

    履歴 編集

    class template
    <locale>

    std::numpunct

    namespace std {
      template <class charT>
      class numpunct : public locale::facet;
    }
    

    概要

    (ここに、クラスの概要を記載する)

    メンバ関数

    名前 説明
    (constructor) コンストラクタ
    decimal_point 小数点の文字を取得する
    thousands_sep 桁区切りの文字を取得する
    grouping 何桁で区切るかの、桁数のシーケンスを取得する
    truename trueを表す文字列を取得する
    falsename falseを表す文字列を取得する

    静的メンバ関数

    名前 説明
    static locale::id id;

    protectedメンバ関数

    名前 説明
    (destructor) デストラクタ
    do_decima_point 小数点の文字を取得する
    do_thousands_sep 桁区切りの文字を取得する
    do_grouping 何桁で区切るかの、桁数のシーケンスを取得する
    do_truename trueを表す文字列を取得する
    do_falsename falseを表す文字列を取得する

    メンバ型

    名前 説明
    char_type 文字型 charT
    string_type 文字列型 basic_string<charT>

    #include <iostream>
    #include <locale>
    
    void print_punct(std::locale&& loc)
    {
      std::cout << loc.name() << std::endl;
    
      const std::numpunct<char>& punct = std::use_facet<std::numpunct<char> >(loc);
    
      // 小数点文字
      std::cout << punct.decimal_point() << std::endl;
    
      // 桁区切り文字
      std::cout << punct.thousands_sep() << std::endl;
    
      // 何桁で区切るかの、桁数のシーケンス
      std::cout << static_cast<int>(punct.grouping()[0]) << std::endl;
    
      std::cout << std::endl;
    }
    
    int main()
    {
      // 日本語
      print_punct(std::locale("Japanese"));
    
      // ドイツ語
      print_punct(std::locale("German"));
    }
    

    出力例

    Japanese_Japan.932
    .
    ,
    3
    
    German_Germany.1252
    ,
    .
    3
    

    参照