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

履歴 編集

function
<regex>

std::regex_traits::isctype(C++11)

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

処理系

参照