std::ctype<CharT>:: scan_not, std::ctype<CharT>:: do_scan_not
From cppreference.net
C++
Text processing library
| Localization library | |||||||||||||||||||||||||
| Regular expressions library (C++11) | |||||||||||||||||||||||||
| Formatting library (C++20) | |||||||||||||||||||||||||
| Null-terminated sequence utilities | |||||||||||||||||||||||||
| Byte strings | |||||||||||||||||||||||||
| Multibyte strings | |||||||||||||||||||||||||
| Wide strings | |||||||||||||||||||||||||
| Primitive numeric conversions | |||||||||||||||||||||||||
|
|||||||||||||||||||||||||
| Text encoding identifications | |||||||||||||||||||||||||
|
|||||||||||||||||||||||||
Localization library
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
std::ctype
| Member functions | ||||
|
ctype::scan_not
ctype::do_scan_not
|
||||
| Member functions of 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 <clocale> #include <iostream> #include <iterator> #include <locale> 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"; }
输出:
'Кошка' 'ネプネプ'
参见
|
使用分类表定位序列中首个不符合给定分类的字符
(
std::ctype
<char>
的公开成员函数)
|
|
|
[virtual]
|
定位序列中首个符合给定分类的字符
(虚受保护成员函数) |