名稱空間
變體
操作

std::ctype<char>::scan_not

來自 cppreference.com
 
 
 
 
 
定義於標頭檔案 <locale>
const char* scan_not( mask m, const char* beg, const char* end ) const;

查詢字元陣列 [begend) 中第一個不滿足分類掩碼 m 的字元,即第一個字元 c 使得 table()[(unsigned char)c] & m 返回 false

(unsigned char)c >= std::ctype<char>::table_size,則替換為實現定義的值,而非 table()[(unsigned char)c],對於不同的 c 值可能不同。

目錄

[編輯] 引數

m - 要搜尋的掩碼
beg - 指向要搜尋字元陣列中第一個字元的指標
end - 指向要搜尋字元陣列末尾之後一個位置的指標

[編輯] 返回值

指向 [begend) 中第一個不滿足掩碼的字元的指標,若未找到此類字元則為 end

[編輯] 注意

與主模板 std::ctype 不同,此特化在分類字元時不會執行虛擬函式呼叫。要自定義行為,派生類可向基類建構函式提供非預設的分類表。

[編輯] 示例

#include <iostream>
#include <iterator>
#include <locale>
 
int main()
{
    auto& f = std::use_facet<std::ctype<char>>(std::locale());
 
    // skip leading whitespace
    char s1[] = "      \t\t\n  Test";
    const char* p1 = f.scan_not(std::ctype_base::space, std::begin(s1), std::end(s1));
    std::cout << '\'' << p1 << "'\n";
 
    // skip leading digits
    char s2[] = "123456789abcd";
    const char* p2 = f.scan_not(std::ctype_base::digit, std::begin(s2), std::end(s2));
    std::cout << '\'' << p2 << "'\n";
}

輸出

'Test'
'abcd'

[編輯] 參閱

[virtual]
在一個序列中定位第一個不符合給定分類的字元
(std::ctype<CharT> 的虛保護成員函式) [編輯]
使用分類表在序列中定位第一個符合給定分類的字元
(公有成員函式) [編輯]