std::ctype<CharT>::scan_not, std::ctype<CharT>::do_scan_not
來自 cppreference.com
定義於標頭檔案 <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 的字元,即第一個字元 c
,使得 is(m, c) 會返回 false。目錄 |
[編輯] 引數
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 leading whitespace 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"; // skip leading digits 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] |
在一個序列中定位第一個符合給定分類的字元 (虛擬保護成員函式) |