std::ctype<CharT>::scan_not, std::ctype<CharT>::do_scan_not
来自cppreference.com
本地化库
本地环境与平面 | |||||||||||||||||||||
本地环境 | |||||||||||||||||||||
平面类别基类 | |||||||||||||||||||||
ctype(字符类别)平面 | |||||||||||||||||||||
numeric(数值)平面 | |||||||||||||||||||||
collate(对照比较)平面 | |||||||||||||||||||||
time(时间)平面 | |||||||||||||||||||||
monetary(货币)平面 | |||||||||||||||||||||
messages(消息)平面 | |||||||||||||||||||||
字符分类与转换 | |||||||||||||||||||||
字符分类 | |||||||||||||||||||||
转换 | |||||||||||||||||||||
|
|||||||||||||||||||||
编码转换平面 | |||||||||||||||||||||
|
|
||||||||||||||||||||
C 本地环境 | |||||||||||||||||||||
std::ctype
成员函数 | ||||
ctype::scan_notctype::do_scan_not
|
||||
ctype<char> 的成员函数 | ||||
在标头
<locale>
定义
|
||
public:
const CharT* scan_not( mask m, const CharT* beg, const CharT* end ) const; |
(1) | |
protected:
virtual const CharT* do_scan_not( mask m, const CharT* beg, const CharT* end) const; |
(2) | |
1) 公开成员函数,调用最终导出类的受保护虚成员函数
do_scan_not
。
2) 定位字符数组
[beg, end)
中不满足分类掩码
m
的首个字符,即首个使得 is(m, c) 会返回 false 的字符 c
。参数
m | - | 要搜索的掩码 |
beg | - | 指向要搜索的数组中首字符的指针 |
end | - | 指向要搜索的数组尾后一位置的指针 |
返回值
指向 [beg, end)
中首个不满足掩码的字符,或若找不到这种字符则为 end
。
示例
运行此代码
#include <locale> #include <clocale> #include <iostream> #include <iterator> int main() { std::setlocale(LC_ALL, "en_US.utf8"); std::wcout.imbue(std::locale("en_US.utf8")); auto& f = std::use_facet<std::ctype<wchar_t>>(std::wcout.getloc()); // 跳过前导空白 wchar_t s1[] = L" \t\t\n Кошка"; const wchar_t* p1 = f.scan_not(std::ctype_base::space, std::begin(s1), std::end(s1)); std::wcout << "'" << p1 << "'\n"; // 跳过前导数字 wchar_t s2[] = L"123456789ネプネプ"; const wchar_t* p2 = f.scan_not(std::ctype_base::digit, std::begin(s2), std::end(s2)); std::wcout << "'" << p2 << "'\n"; }
输出:
'Кошка' 'ネプネプ'
See also
用分类表定位序列中首个不符合给定分类的字符 ( std::ctype<char>
的公开成员函数) |
|
[虚]
|
定位序列中首个符合给定分类的字符 (虚受保护成员函数) |