std::ctype<char>::scan_not
来自cppreference.com
< cpp | locale | ctype char
在标头 <locale> 定义
|
||
const char* scan_not( mask m, const char* beg, const char* end ) const; |
||
在字符数组 [
beg,
end)
中定位不满足分类掩码 m 的首个字符,即满足 table()[(unsigned char) c] & m 会返回 false 的首个 c
。
若 (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()); // 跳过前导空白符 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"; // 跳过前导数位 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> 的虚受保护成员函数) |
用分类表定位序列中首个符合给定分类的字符 (公开成员函数) |