std::ctype<CharT>::scan_is, std::ctype<CharT>::do_scan_is
来自 cppreference.cn
定义于头文件 <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 的字符,即首个字符 c 使得 is(m, c) 会返回 true。目录 |
[编辑] 参数
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()); // skip until the first letter 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"; // skip until the first letter 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++ 标准。
DR | 应用于 | 发布时的行为 | 正确的行为 |
---|---|---|---|
LWG 152 | C++98 | do_scan_is 的效果提及 is(m),但 is 不具有这种重载 |
更正为 is(m, c) |
[编辑] 参见
使用分类表定位序列中首个符合给定分类的字符 ( std::ctype<char> 的公有成员函数) | |
[虚函数] |
定位序列中首个不符合给定分类的字符 (虚保护成员函数) |