• Class / Function / Type

      std::
    • Header file

      <>
    • Other / All

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

    履歴 編集

    function
    <regex>

    std::regex_traits::isctype

    bool isctype(char_type c, char_class_type f) const;
    

    概要

    文字cがクラスfに属しているかを判定する。

    戻り値

    ビットマスクのクラス値fに含まれるいずれかのクラスに文字cが属していればtrue、そうでなければfalseを返す。

    #include <iostream>
    #include <regex>
    #include <string>
    
    int main()
    {
      std::regex_traits<char> traits;
    
      std::string class_name = "alnum"; // 正規表現中で[[:alnum:]]のように入力するクラス名
    
      // 文字'a'がアルファベットと数字のクラスに含まれているかを判定する
      std::regex_traits<char>::char_class_type class_value =
        traits.lookup_classname(class_name.begin(), class_name.end());
      if (traits.isctype('a', class_value)) {
        std::cout << "'a' is alpha-numeric class" << std::endl;
      }
      else {
        std::cout << "'a' is not alpha-numeric class" << std::endl;
      }
    }
    

    出力

    'a' is alpha-numeric class
    

    バージョン

    言語

    • C++11

    処理系

    • Clang: 3.0 , 3.1 , 3.2 , 3.3 , 3.4 , 3.5 , 3.6
    • GCC: 4.9.0 , 4.9.1 , 4.9.2 , 5.0.0
    • ICC: ??
    • Visual C++: ??

    参照