standard facet is used to classify and convert characters.
objects are prevented to be locally constructed by having a protected destructor. Only those installed in locale
objects should be used through mechanisms such as use_facet
This template class has one template parameter, representing the character type with which the facet works. This template parameter is referred in this entire reference as charT
It includes the following public member functions:
|is|| Classify characters (public member function)|
|scan_is|| Return first character in category (public member function)|
|scan_not|| Return first character not in category (public member function)|
|toupper|| Convert to uppercase (public member function)|
|tolower|| Convert to lowercase (public member function)|
|widen|| Widen character(s) (public member function)|
|narrow|| Narrow character(s) (public member function)|
It also declares the following alias type:
|char_type|| Internal character type (public member type)|
And inherits the following type:
|mask|| Character category bitmask type (member type)|
Virtual protected members
The class defines the virtual protected members in charge of implementing the expected behavior of their respective public member functions:
|do_is|| Classify characters [virtual] (virtual protected member function)|
|do_scan_is|| Return first character in category [virtual] (virtual protected member function)|
|do_scan_not|| Return first character not in category [virtual] (virtual protected member function)|
|do_toupper|| Convert to uppercase [virtual] (virtual protected member function)|
|do_tolower|| Convert to lowercase [virtual] (virtual protected member function)|
|do_widen|| Widen character(s) [virtual] (virtual protected member function)|
|do_narrow|| Narrow character(s) [virtual] (virtual protected member function)|
Along with the class destructor:
ctype specialization: ctype<char>
version is specialized, so that some of their member functions can be implemented inline
instead of calling their do_
counterpart (this is the case for members is
The constructor for this specialization is different than the one for the general template (see ctype::ctype
for more info).
This specialization keeps an internal table
array member. This private member is an array of elements of type ctype::mask
containing the classification of each of the characters in the character set: The value of each element in the array corresponds to the classification of the character given by its order position. In other words, the table
is what member ctype::is
would return for an array of char
elements whose values are the sequence of values a char
element can take, from 0 to its highest value.
The highest value in the table is given by public member constant ctype::table_size
(which is, at least, 256).
Also, two additional protected members are provided in this specialization to access the table
- const mask* table () const throw;
- Returns the table being used by the object. This is either the first argument used in the constructor, or the classic table if zero was used as first argument for the constructor.
- static const mask* classic_table () throw;
- Returns the classic table, which is a default table used in case none is provided in the constructor.