C++ 本地化庫 - scan_not



描述

它返回範圍內第一個不在指定類別中的字元,即返回在[low,high)範圍內第一個不屬於m中指定任何類別的字元。如果在該範圍內找不到這樣的字元,則返回high。

宣告

以下是 std::ctype::scan_not 的宣告。

C++98

	
const char_type* scan_not (mask m, const char_type* low, const char_type* high) const;

C++11

const char_type* scan_not (mask m, const char_type* low, const char_type* high) const;

引數

  • m − 它是成員型別 mask 的位掩碼。

  • low,high − 它們是指向字元序列的開始和結束位置的指標。

返回值

它返回指向範圍內第一個符合分類的元素的指標,如果找不到則返回 high。

異常

強保證 − 如果丟擲異常,則沒有任何影響。

資料競爭

訪問物件以及 [low,high) 範圍內的元素。

示例

下面的例子解釋了 std::ctype::scan_not。

#include <iostream>
#include <locale>

int main () {
   std::locale loc;

   const char period[] = "june2018";

   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
locale.htm
廣告