C++ 本地化庫 - scan_is



描述

它返回類別中的第一個字元。

宣告

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

C++98

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

C++11

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

引數

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

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

返回值

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

異常

強保證 − 如果丟擲異常,則沒有效果。

資料競爭

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

示例

以下示例說明了 std::ctype::scan_is。

#include <iostream>
#include <locale>

int main () {
   std::locale loc;

   const char quote[] = "tutorialspoint. sairamkrishna, He had developed this tutorial.";

   const char * p = std::use_facet< std::ctype<char> >(loc).scan_is 
      ( std::ctype<char>::punct, quote, quote+76 );

   std::cout << "The second sentence is: " << p << '\n';

   return 0;
}

讓我們編譯並執行以上程式,這將產生以下結果:

The second sentence is: . sairamkrishna, He had developed this tutorial.
locale.htm
廣告