public member function
<locale>

std::ctype::scan_is

const char_type* scan_is (mask m, const char_type* low, const char_type* high) const;
Return first character in category
Returns the first character in the range [low,high) that classifies into any of the categories specified in m. If no such character is found in the range, high is returned.

In ctype's generic template, this function simply calls the virtual protected member do_scan_is, which does the above by default.

In the char specialization (ctype<char>), this function uses the internal table to directly return the results without calling any virtual member.

Parameters

m
Bitmask of member type mask (inherited from ctype_base) specifying the categories to scan for. If the bitmask combines more than one category, the function returns a pointer to the first character that belongs to any of the categories.
It may be any bitwise combination of the following member bitmask values:
member constantvaluedescription
spaceunspecified (unique bits)white-space character
printunspecified (unique bits)printable character
cntrlunspecified (unique bits)control character
upperunspecified (unique bits)uppercase letter
lowerunspecified (unique bits)lowercase letter
alphaunspecified (unique bits)alphabetic character
digitunspecified (unique bits)decimal digit
punctunspecified (unique bits)punctuation character
xdigitunspecified (unique bits)hexadecimal digit
alnumalpha|digitalpha-numeric character
graphalnum|punctcharacter with graphic representation
member constantvaluedescription
spaceunspecified (unique bits)white-space character
printunspecified (unique bits)printable character
cntrlunspecified (unique bits)control character
upperunspecified (unique bits)uppercase letter
lowerunspecified (unique bits)lowercase letter
alphaunspecified (unique bits)alphabetic character
digitunspecified (unique bits)decimal digit
punctunspecified (unique bits)punctuation character
xdigitunspecified (unique bits)hexadecimal digit
blankunspecified (unique bits)blank character
alnumalpha|digitalpha-numeric character
graphalnum|punctcharacter with graphic representation
See <cctype> for details on how ASCII characters are classified with respect to these categories.
low, high
Pointer to the beginning and end of the sequence of characters. The range used is [low,high), which contains all the characters between low and high, including the character pointed by low but not the character pointed by high.
Note that null characters (if any) are also considered, and the function proceeds beyond them, until a match is found or the entire range is completed.
Member type char_type is the facet's character type (defined as an alias of ctype's template parameter, charT).

Return value

A pointer to the first element in the range that classifies, or high if none is found.
Member type char_type is the facet's character type (defined as an alias of ctype's template parameter, charT).

Example

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

int main ()
{
  std::locale loc;

  const char quote[] = "Characters do not change. Opinions alter, but characters are only developed.";
                       // (quoting Benjamin Disraeli)

  // get a pointer to the first "punctuation" character:
  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;
}

Output:

The second sentence is: . Opinions alter, but characters are only developed.


Data races

The object, and the elements in the range [low,high), are accessed.

Exception safety

Strong guarantee: if an exception is thrown, there are no changes in the object.

See also