namespace std {
class ctype_base;
}
概要
ctype_baseは、ctypeが使用する文字分類のためのビットマスク型と、その定数を定義する基底クラスである。
ctypeはこのクラスを継承しており、ctype::is()などのメンバ関数へ渡す分類の指定にこれらの定数を使用する。複数の分類は|で組み合わせられる。
メンバ型
| 名前 | 説明 |
|---|---|
mask |
ビットマスクの整数型 |
メンバ定数
| 名前 | 説明 | 対応バージョン |
|---|---|---|
static const mask space = 1 << 0;static constexpr mask space = 1 << 0; |
空白類文字のマスク値 | C++98 C++26 |
static const mask print = 1 << 1;static constexpr mask print = 1 << 1; |
印字可能文字のマスク値 | C++98 C++26 |
static const mask cntrl = 1 << 2;static constexpr mask cntrl = 1 << 2; |
制御文字のマスク値 | C++98 C++26 |
static const mask upper = 1 << 3;static constexpr mask upper = 1 << 3; |
英大文字のマスク値 | C++98 C++26 |
static const mask lower = 1 << 4;static constexpr mask lower = 1 << 4; |
英小文字のマスク値 | C++98 C++26 |
static const mask alpha = 1 << 5;static constexpr mask alpha = 1 << 5; |
英字のマスク値 | C++98 C++26 |
static const mask digit = 1 << 6;static constexpr mask digit = 1 << 6; |
数字のマスク値 | C++98 C++26 |
static const mask punct = 1 << 7;static constexpr mask punct = 1 << 7; |
区切り文字のマスク値 | C++98 C++26 |
static const mask xdigit = 1 << 8;static constexpr mask xdigit = 1 << 8; |
十六進数字のマスク値 | C++98 C++26 |
static const mask blank = 1 << 9;static constexpr mask blank = 1 << 9; |
ブランク文字のマスク値 | C++11 C++26 |
static const mask alnum = alpha | digit;static constexpr mask alnum = alpha | digit; |
英字・数字のマスク値 | C++98 C++26 |
static const mask graph = alnum | punct;static constexpr mask graph = alnum | punct; |
図形文字のマスク値 | C++98 C++26 |
例
#include <iostream>
#include <locale>
int main()
{
const auto& ct = std::use_facet<std::ctype<char>>(std::locale::classic());
std::cout << std::boolalpha;
// 複数の分類を|で組み合わせて指定できる
std::cout << ct.is(std::ctype_base::alpha | std::ctype_base::digit, '5') << std::endl;
std::cout << ct.is(std::ctype_base::punct, '5') << std::endl;
}
出力
true
false
バージョン
言語
- C++98
関連項目
参照
- LWG Issue 4037. Static data members of
ctype_baseare not yet required to be usable in constant expressions- C++26で、各メンバ定数が
static constからstatic constexprに変更され、定数式で使用できることが規定された
- C++26で、各メンバ定数が