std::ctype<CharT>::scan_not, std::ctype<CharT>::do_scan_not
来自cppreference.com
| 在标头 <locale> 定义
|
||
| |
(1) | |
| |
(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";
}
输出:
'Кошка'
'ネプネプ'
See also
| 用分类表定位序列中首个不符合给定分类的字符 ( std::ctype<char> 的公开成员函数) | |
[虚] |
定位序列中首个符合给定分类的字符 (虚受保护成员函数) |