| Localization library | |||||||||||||||||||||||||
| Regular expressions library(C++11) | |||||||||||||||||||||||||
| Formatting library(C++20) | |||||||||||||||||||||||||
| Null-terminated sequence utilities | |||||||||||||||||||||||||
| Byte strings | |||||||||||||||||||||||||
| Multibyte strings | |||||||||||||||||||||||||
| Wide strings | |||||||||||||||||||||||||
| Primitive numeric conversions | |||||||||||||||||||||||||
| |||||||||||||||||||||||||
| Text encoding identifications | |||||||||||||||||||||||||
| |||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Defined in header <locale> | ||
template<class CharT> class ctype_byname:publicstd::ctype<CharT>; | ||
std::ctype_byname is astd::ctype facet which encapsulates character classification rules of the locale specified at its construction.
Contents |
The standard library is guaranteed to provide the following specializations:
Defined in header <locale> | |
| std::ctype_byname<char> | provides narrow character classification (uses table lookup for character classification) |
| std::ctype_byname<wchar_t> | provides wide character classification |
| Type | Definition |
mask | typenamestd::ctype<CharT>::mask |
(constructor) | constructs a newctype_byname facet(public member function)[edit] |
(destructor) | destroys actype_byname facet(protected member function)[edit] |
explicit ctype_byname(constchar* name,std::size_t refs=0); | ||
explicit ctype_byname(conststd::string& name,std::size_t refs=0); | (since C++11) | |
Constructs a newstd::ctype_byname facet for a locale withname.
refs is used for resource management: ifrefs==0, the implementation destroys the facet, when the laststd::locale object holding it is destroyed. Otherwise, the object is not destroyed.
| name | - | the name of the locale |
| refs | - | the number of references that link to the facet |
protected: ~ctype_byname(); | ||
Destroys the facet.
CharT is notchar)| Type | Definition |
char_type | CharT |
| Member | Description |
std::locale::idid[static] | the identifier of thefacet |
invokesdo_is(public member function of std::ctype<CharT>)[edit] | |
invokesdo_scan_is(public member function of std::ctype<CharT>)[edit] | |
invokesdo_scan_not(public member function of std::ctype<CharT>)[edit] | |
invokesdo_toupper(public member function of std::ctype<CharT>)[edit] | |
invokesdo_tolower(public member function of std::ctype<CharT>)[edit] | |
invokesdo_widen(public member function of std::ctype<CharT>)[edit] | |
invokesdo_narrow(public member function of std::ctype<CharT>)[edit] |
[virtual] | converts a character or characters to uppercase (virtual protected member function of std::ctype<CharT>)[edit] |
[virtual] | converts a character or characters to lowercase (virtual protected member function of std::ctype<CharT>)[edit] |
[virtual] | converts a character or characters fromchar toCharT(virtual protected member function of std::ctype<CharT>)[edit] |
[virtual] | converts a character or characters fromCharT tochar(virtual protected member function of std::ctype<CharT>)[edit] |
[virtual] | classifies a character or a character sequence (virtual protected member function of std::ctype<CharT>)[edit] |
[virtual] | locates the first character in a sequence that conforms to given classification (virtual protected member function of std::ctype<CharT>)[edit] |
[virtual] | locates the first character in a sequence that fails given classification (virtual protected member function of std::ctype<CharT>)[edit] |
CharT ischar)| Type | Definition |
char_type | char |
| Member | Description |
std::locale::idid[static] | the identifier of thefacet |
conststd::size_ttable_size[static] | size of the classification table, at least 256 |
| obtains the character classification table (public member function of std::ctype<char>)[edit] | |
[static] | obtains the "C" locale character classification table (public static member function of std::ctype<char>)[edit] |
| classifies a character or a character sequence, using the classification table (public member function of std::ctype<char>)[edit] | |
| locates the first character in a sequence that conforms to given classification, using the classification table (public member function of std::ctype<char>)[edit] | |
| locates the first character in a sequence that fails given classification, using the classification table (public member function of std::ctype<char>)[edit] | |
invokesdo_toupper(public member function of std::ctype<CharT>)[edit] | |
invokesdo_tolower(public member function of std::ctype<CharT>)[edit] | |
invokesdo_widen(public member function of std::ctype<CharT>)[edit] | |
invokesdo_narrow(public member function of std::ctype<CharT>)[edit] |
[virtual] | converts a character or characters to uppercase (virtual protected member function of std::ctype<CharT>)[edit] |
[virtual] | converts a character or characters to lowercase (virtual protected member function of std::ctype<CharT>)[edit] |
[virtual] | converts a character or characters fromchar toCharT(virtual protected member function of std::ctype<CharT>)[edit] |
[virtual] | converts a character or characters fromCharT tochar(virtual protected member function of std::ctype<CharT>)[edit] |
| Type | Definition |
mask | unspecifiedBitmaskType type (enumeration, integer type, or bitset) |
space [static] | the value ofmask identifying whitespace character classification(public static member constant) |
print [static] | the value ofmask identifying printable character classification(public static member constant) |
cntrl [static] | the value ofmask identifying control character classification(public static member constant) |
upper [static] | the value ofmask identifying uppercase character classification(public static member constant) |
lower [static] | the value ofmask identifying lowercase character classification(public static member constant) |
alpha [static] | the value ofmask identifying alphabetic character classification(public static member constant) |
digit [static] | the value ofmask identifying digit character classification(public static member constant) |
punct [static] | the value ofmask identifying punctuation character classification(public static member constant) |
xdigit [static] | the value ofmask identifying hexadecimal digit character classification(public static member constant) |
blank [static](C++11) | the value ofmask identifying blank character classification(public static member constant) |
alnum [static] | alpha| digit (public static member constant) |
graph [static] | alnum| punct (public static member constant) |
std::ctype_byname<char> was incorrectly declared as an explicit specialization in the synopsis of<locale>, and the declaration was removed by the resolution ofLWG issue 1298, but it remains a required specialization, just likestd::ctype_byname<wchar_t>.
#include <iostream>#include <locale> int main(){wchar_t c= L'\u00de';// capital letter thorn std::locale loc("C"); std::cout<<"isupper('Þ', C locale) returned "<<std::boolalpha<<std::isupper(c, loc)<<'\n'; loc=std::locale(loc, new std::ctype_byname<wchar_t>("en_US.utf8")); std::cout<<"isupper('Þ', C locale with Unicode ctype) returned "<<std::boolalpha<<std::isupper(c, loc)<<'\n';}
Output:
isupper('Þ', C locale) returned falseisupper('Þ', C locale with Unicode ctype) returned trueThe following behavior-changing defect reports were applied retroactively to previously published C++ standards.
| DR | Applied to | Behavior as published | Correct behavior |
|---|---|---|---|
| LWG 16 | C++98 | the definition of the explicit specializationstd::ctype_byname<char> misspecified the name and parameter list of do_narrow | corrected |
| LWG 616 | C++98 | thetypename disambiguator was missing in the definition ofmask | added |
| defines character classification tables (class template)[edit] | |
| specialization ofstd::ctype for typechar (class template specialization)[edit] |