std::ctype<char>::scan_is
來自 cppreference.com
< cpp | 本地化 | ctype char
定義於標頭檔案 <locale> |
||
const char* scan_is( mask m, const char* beg, const char* end ) const; |
(1) | |
在字元陣列 [
beg,
end)
中定位第一個滿足分類掩碼 m 的字元,即第一個字元 c
使得 table()[(unsigned char) c] & m 返回 true。
如果 (unsigned char)c >= std::ctype<char>::table_size,則會用一個實現定義的值替換 table()[(unsigned char)c],對於不同的 c 值可能不同。
目錄 |
[編輯] 引數
m | - | 要搜尋的掩碼 |
beg | - | 指向要搜尋字元陣列中第一個字元的指標 |
end | - | 指向要搜尋字元陣列末尾之後一個位置的指標 |
[編輯] 返回值
指向 [
beg,
end)
中滿足掩碼的第一個字元的指標,如果沒有找到這樣的字元,則返回 end。
[編輯] 注意
與主模板 std::ctype 不同,此特化在分類字元時不會執行虛擬函式呼叫。要自定義行為,派生類可以向基類建構函式提供非預設分類表。
[編輯] 示例
執行此程式碼
#include <iostream> #include <iterator> #include <locale> int main() { std::locale loc(""); auto& f = std::use_facet<std::ctype<char>>(loc); // skip until the first letter char s1[] = " \t\t\n Test"; const char* p1 = f.scan_is(std::ctype_base::alpha, std::begin(s1), std::end(s1)); std::cout << '\'' << p1 << "'\n"; // skip until the first letter char s2[] = "123456789abcd"; const char* p2 = f.scan_is(std::ctype_base::alpha, std::begin(s2), std::end(s2)); std::cout << '\'' << p2 << "'\n"; }
輸出
'Test' 'abcd'
[編輯] 參閱
[virtual] |
在一個序列中定位第一個符合給定分類的字元 ( std::ctype<CharT> 的虛保護成員函式) |
使用分類表在序列中定位第一個不符合給定分類的字元 (公有成員函式) |