public member function
<locale>

std::ctype::scan_not

const char_type* scan_not (mask m, const char_type* low, const char_type* high) const;
返回分類中的第一個字元
返回範圍 [low,high) 中第一個不屬於 m 指定的任何類別的字元。如果在範圍內未找到此類字元,則返回 high

ctype 的泛型模板中,此函式僅呼叫虛保護成員 do_scan_not,該成員預設執行上述操作。

char 特化 (ctype<char>) 中,此函式使用內部 table 直接返回結果,而不呼叫任何虛成員。

引數

m
型別為 mask (繼承自 ctype_base) 的成員位掩碼,指定要掃描的類別。如果位掩碼組合了多個類別,則函式返回指向不屬於**任何**類別的第一個字元的指標。
它可以是以下成員位掩碼值的任何按位組合
成員常量描述
spaceunspecified (unique bits)white-space character
printunspecified (unique bits)可列印字元
cntrlunspecified (unique bits)控制字元
upperunspecified (unique bits)大寫字母
lowerunspecified (unique bits)小寫字母
alphaunspecified (unique bits)字母字元
digitunspecified (unique bits)decimal digit
punctunspecified (unique bits)punctuation character
xdigitunspecified (unique bits)hexadecimal digit
alnumalpha|digitalpha-numeric character
graphalnum|punctcharacter with graphic representation
成員常量描述
spaceunspecified (unique bits)white-space character
printunspecified (unique bits)可列印字元
cntrlunspecified (unique bits)控制字元
upperunspecified (unique bits)大寫字母
lowerunspecified (unique bits)小寫字母
alphaunspecified (unique bits)字母字元
digitunspecified (unique bits)decimal digit
punctunspecified (unique bits)punctuation character
xdigitunspecified (unique bits)hexadecimal digit
blankunspecified (unique bits)空白字元
alnumalpha|digitalpha-numeric character
graphalnum|punctcharacter with graphic representation
有關 ASCII 字元如何根據這些類別進行分類的詳細資訊,請參閱 <cctype>
low, high
指向字元序列的開頭和結尾的指標。使用的範圍是 [low,high),它包含 lowhigh 之間的所有字元,包括 low 指向的字元,但不包括 high 指向的字元。
請注意,*空字元*也會被考慮在內,函式可能會在它們之後繼續查詢,直到找到匹配項或完成整個範圍。
成員型別 char_type 是字面量的字元型別(定義為 ctype 的模板引數 charT 的別名)。

返回值

指向範圍內第一個不分類的元素,或者如果未找到則為 high 的指標。
成員型別 char_type 是字面量的字元型別(定義為 ctype 的模板引數 charT 的別名)。

示例

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// ctype::scan_not example
#include <iostream>       // std::cout
#include <locale>         // std::locale, std::ctype, std::use_facet

int main ()
{
  std::locale loc;

  const char period[] = "November2008";

  const char * p = std::use_facet< std::ctype<char> >(loc).scan_not ( std::ctype<char>::alpha, period, period+12 );

  std::cout << "The first non-alphabetic character is: " << *p << '\n';

  return 0;
}

輸出

The first non-alphabetic character is: 2.


資料競爭

物件和範圍 [low,high) 中的元素被訪問。

異常安全

強保證:如果丟擲異常,物件將不發生任何更改。

另見