regex_traits::isctype
Tests for class membership.
Syntax
bool isctype(char_type ch, char_class_type cls) const;
Parameters
ch
The element to test.cls
The classes to test for.
Remarks
The member function returns true only if the character ch is in the character class designated by cls.
Example
// std_tr1__regex__regex_traits_isctype.cpp
// compile with: /EHsc
#include <regex>
#include <iostream>
typedef std::regex_traits<char> Mytr;
int main()
{
Mytr tr;
Mytr::char_type ch = tr.translate('a');
std::cout << "translate('a') == 'a' == " << std::boolalpha
<< (ch == 'a') << std::endl;
std::cout << "nocase 'a' == 'A' == " << std::boolalpha
<< (tr.translate_nocase('a') == tr.translate_nocase('A'))
<< std::endl;
const char *lbegin = "abc";
const char *lend = lbegin + strlen(lbegin);
Mytr::size_type size = tr.length(lbegin);
std::cout << "length(\"abc\") == " << size <<std::endl;
Mytr::string_type str = tr.transform(lbegin, lend);
std::cout << "transform(\"abc\") < \"abc\" == " << std::boolalpha
<< (str < "abc") << std::endl;
const char *ubegin = "ABC";
const char *uend = ubegin + strlen(ubegin);
std::cout << "primary \"ABC\" < \"abc\" == " << std::boolalpha
<< (tr.transform_primary(ubegin, uend) <
tr.transform_primary(lbegin, lend))
<< std::endl;
const char *dig = "digit";
Mytr::char_class_type cl = tr.lookup_classname(dig, dig + 5);
std::cout << "class digit == d == " << std::boolalpha
<< (cl == tr.lookup_classname(dig, dig + 1))
<< std::endl;
std::cout << "'3' is digit == " <<std::boolalpha
<< tr.isctype('3', tr.lookup_classname(dig, dig + 5))
<< std::endl;
std::cout << "hex C == " << tr.value('C', 16) << std::endl;
// other members
str = tr.lookup_collatename(dig, dig + 5);
Mytr::locale_type loc = tr.getloc();
tr.imbue(loc);
return (0);
}
translate('a') == 'a' == true nocase 'a' == 'A' == true length("abc") == 3 transform("abc") < "abc" == false primary "ABC" < "abc" == false class digit == d == true '3' is digit == true hex C == 12
Requirements
Header: <regex>
Namespace: std