is
描述 (Description)
这是一个分类字符。
声明 (Declaration)
以下是std :: ctype :: is的声明。
C++98
bool is (mask m, char_type c) const;
const char_type* is (const char_type* low,
const char_type* high, mask* vec) const;
C++11
bool is (mask m, char_type c) const;
const char_type* is (const char_type* low,
const char_type* high, mask* vec) const;
参数 (Parameters)
m - 它是成员类型掩码的位掩码。
c - 这是一个分类的角色。
vec - 它是一个目标数组。
返回值 (Return Value)
如果c在作为掩码m传递的任何类别中进行分类,则返回true。
异常 (Exceptions)
Strong guarantee - 如果抛出异常,则没有任何影响。
数据竞争 (Data races)
访问区域设置对象。
例子 (Example)
在下面的例子中解释了std :: ctype :: is。
#include <iostream>
#include <locale>
int main () {
std::locale loc;
const char quote[] = "IoWiki is a one of the best site .";
std::cout << '"' << quote << "\"\n";
std::cout << "The quote begins with an uppercase letter? ";
std::cout << std::boolalpha;
std::cout << std::use_facet< std::ctype<char> >(loc).is (std::ctype
<char>::upper, quote[0]);
std::cout << '\n';
int cx = 0;
std::ctype<char>::mask * masks = new std::ctype<char>::mask [60];
std::use_facet< std::ctype<char> >(loc).is (quote, quote+60, masks);
for (int i=0; i<60; ++i) if (masks[i] & std::ctype<char>::space) ++cx;
std::cout << "The quote has " << cx << " whitespaces.\n";
return 0;
}
让我们编译并运行上面的程序,这将产生以下结果 -
"IoWiki is a one of the best site ."
The quote begins with an uppercase letter? true
The quote has 8 whitespaces.