public member function
<locale>
std::ctype::scan_not
const char_type* scan_not (mask m, const char_type* low, const char_type* high) const;
Return first character not in category
Returns the first character in the range [low,high)
that does not classify 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_not, 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 does not belong to any of the categories.
It may be any bitwise combination of the following member bitmask values:
member constant | value | description |
space | unspecified (unique bits) | white-space character |
print | unspecified (unique bits) | printable character |
cntrl | unspecified (unique bits) | control character |
upper | unspecified (unique bits) | uppercase letter |
lower | unspecified (unique bits) | lowercase letter |
alpha | unspecified (unique bits) | alphabetic character |
digit | unspecified (unique bits) | decimal digit |
punct | unspecified (unique bits) | punctuation character |
xdigit | unspecified (unique bits) | hexadecimal digit |
alnum | alpha|digit | alpha-numeric character |
graph | alnum|punct | character with graphic representation |
member constant | value | description |
space | unspecified (unique bits) | white-space character |
print | unspecified (unique bits) | printable character |
cntrl | unspecified (unique bits) | control character |
upper | unspecified (unique bits) | uppercase letter |
lower | unspecified (unique bits) | lowercase letter |
alpha | unspecified (unique bits) | alphabetic character |
digit | unspecified (unique bits) | decimal digit |
punct | unspecified (unique bits) | punctuation character |
xdigit | unspecified (unique bits) | hexadecimal digit |
blank | unspecified (unique bits) | blank character |
alnum | alpha|digit | alpha-numeric character |
graph | alnum|punct | character 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 are also considered, and the function may proceed 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 does not classify, 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
|
// 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;
}
|
Output:
The first non-alphabetic character is: 2.
|
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
- ctype::is
- Classify characters (public member function)
- ctype::scan_is
- Return first character in category (public member function)
- ctype::do_scan_not
- Return first character not in category [virtual] (protected virtual member function)