std::ctype<CharT>::scan_is, std::ctype<CharT>::do_scan_is
來自 cppreference.com
定義於標頭檔案 <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++ 標準。
缺陷報告 | 應用於 | 釋出時的行為 | 正確的行為 |
---|---|---|---|
LWG 152 | C++98 | do_scan_is 的效果提到了 is(m),但 is 沒有這樣的過載 |
更正為 is(m, c) |
[編輯] 參閱
使用分類表在序列中定位第一個符合給定分類的字元 ( std::ctype<char> 的公有成員函式) | |
[虛] |
在一個序列中定位第一個不符合給定分類的字元 (虛受保護成員函式) |