std::ctype<char>::scan_not
来自 cppreference.cn
< cpp | locale | ctype char
定义于头文件 <locale> |
||
const char* scan_not( mask m, const char* beg, const char* end ) const; |
||
在字符数组 [
beg,
end)
中定位首个不满足分类掩码 m 的字符,即首个字符 c
使得 table()[(unsigned char)c] & m 返回 false。
若 (unsigned char)c >= std::ctype<char>::table_size,则会代入实现定义的数值,而非 table()[(unsigned char)c],对于 c 的不同值,此数值可能不同。
目录 |
[编辑] 参数
m | - | 要搜索的掩码 |
beg | - | 指向要搜索的字符数组中首个字符的指针 |
end | - | 指向要搜索的字符数组的末尾后一个位置的指针 |
[编辑] 返回值
指向 [
beg,
end)
中首个不满足掩码的字符的指针;若未找到此类字符,则返回 end。
[编辑] 注意
与主模板 std::ctype 不同,此特化在分类字符时,不执行虚函数调用。要定制行为,派生类可以向基类构造函数提供非默认的分类表。
[编辑] 示例
运行此代码
#include <iostream> #include <iterator> #include <locale> int main() { auto& f = std::use_facet<std::ctype<char>>(std::locale()); // skip leading whitespace char s1[] = " \t\t\n Test"; const char* p1 = f.scan_not(std::ctype_base::space, std::begin(s1), std::end(s1)); std::cout << '\'' << p1 << "'\n"; // skip leading digits char s2[] = "123456789abcd"; const char* p2 = f.scan_not(std::ctype_base::digit, std::begin(s2), std::end(s2)); std::cout << '\'' << p2 << "'\n"; }
输出
'Test' 'abcd'
[编辑] 参见
[虚函数] |
定位序列中首个不符合给定分类的字符 ( std::ctype<CharT> 的虚保护成员函数) |
使用分类表,定位序列中首个符合给定分类的字符 (公有成员函数) |