std::ctype<CharT>:: scan_is, std::ctype<CharT>:: do_scan_is
From cppreference.net
|
定义于头文件
<locale>
|
||
|
public
:
const CharT * scan_is ( mask m, const CharT * beg, const CharT * end ) const ; |
(1) | |
|
protected
:
virtual const CharT * do_scan_is ( mask m, const CharT * beg, const CharT * end ) const ; |
(2) | |
1)
公开成员函数,调用最终派生类的受保护虚成员函数
do_scan_is
。
2)
定位字符数组
[
beg
,
end
)
中首个满足分类掩码
m
的字符,即首个使
is
(
m, c
)
返回
true
的字符
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_is(std::ctype_base::alpha, std::begin(s1), std::end(s1)); std::wcout << '\'' << p1 << "'\n"; // 跳过直到第一个字母 wchar_t s2[] = L"123456789ネプネプ"; const wchar_t* p2 = f.scan_is(std::ctype_base::alpha, std::begin(s2), std::end(s2)); std::wcout << '\'' << p2 << "'\n"; }
输出:
'Кошка' 'ネプネプ'
缺陷报告
下列行为变更缺陷报告被追溯应用于先前发布的C++标准。
| 缺陷报告 | 应用于 | 发布时行为 | 正确行为 |
|---|---|---|---|
| LWG 152 | C++98 |
do_scan_is
的效果提及了
is
(
m
)
,
但 is 没有这样的重载 |
修正为 is ( m, c ) |
参见
|
在字符序列中定位首个符合指定分类要求的字符,使用分类表
(
std::ctype
<char>
的公开成员函数)
|
|
|
[virtual]
|
在字符序列中定位首个不符合指定分类要求的字符
(虚函数保护成员函数) |