std::regex_traits::isctype (3) Linux Manual Page
std::regex_traits<CharT>::isctype – std::regex_traits<CharT>::isctype
Synopsis
bool isctype(CharT c, char_class_type f) const;
Determines whether the character c belongs to the character class identified by f, which, in turn, is a value returned by lookup_classname() or a bitwise OR of several such values.
The version of this function provided in the standard library specializations of std::regex_traits does the following:
1) First converts f to some temporary value m of type std::ctype_base::mask in implementation-defined manner
2) Then attempts to classify the character in the imbued locale by calling std::use_facet<std::ctype<CharT>>(getloc()).is(m, c). If that returned true, true is returned by isctype().
3) Otherwise, checks whether c equals ‘_’ and the bitmask f includes the result of calling lookup_classname() for the character class [:w:], in which case true is returned.
4) Otherwise, false is returned.
Parameters
c – the character to classify
f – the bitmask obtained from one or several calls to lookup_classname()
Return value
true if c is classified by f, false otherwise.
Notes
The description above summarizes C++14; the C++11 phrasing required this function to return true for ‘_’ in all cases (LWG_issue_2018)
Example
// Run this code
#include <iostream>
#include <string>
#include <regex>
int main()
{
std::regex_traits<char> t;
std::string str_alnum = "alnum";
auto a = t.lookup_classname(str_alnum.begin(), str_alnum.end());
std::string str_w = "w"; // [:w:] is [:alnum:] plus '_'
auto w = t.lookup_classname(str_w.begin(), str_w.end());
std::cout << std::boolalpha
<< t.isctype('A', w) << ' ' << t.isctype('A', a) << '\n'
<< t.isctype('_', w) << ' ' << t.isctype('_', a) << '\n'
<< t.isctype(' ', w) << ' ' << t.isctype(' ', a) << '\n';
}
Output:
demonstraits a custom regex_traits implementation of lookup_classname/isctype
// Run this code
Output:
See also
lookup_classname (public member function)
do_is classifies a character or a character sequence
[virtual]
iswctype (function)
