Reference

class template
<locale>

std::ctype

template <class charT> class ctype;
Character type facet

The ctype standard facet classifies and transforms characters, adapting the functionality of the C library header <cctype> to C++ locales.

The ctype class template has a protected destructor: Programs shall only construct objects of derived classes, or use those installed in locale objects (through use_facet ).

All standard locale objects support at least the following facet instantiations of the ctype class template as part of the ctype category:
facets in locale objectsdescription
ctype<char>narrow characters
produces the same results as the functions in header <cctype> for the classic locale * specialized with a particular implementation (see specializations below)
ctype<wchar_t>wide characters

Template parameters

charT
Character type.
Aliased as member char_type.

Member types

member typedefinitiondescription
char_typeThe template parameter (charT)Character type
The class also inherits ctype_base::mask , which is used extensively as a parameter and return type by member functions (see ctype_base ).

Member constants

The following member constants are inherited from ctype_base ; They are used to identify character categories.
member constanttypevaluedescription
spacectype_base::maskunspecified (unique bits)white-space character
printctype_base::maskunspecified (unique bits)printable character
cntrlctype_base::maskunspecified (unique bits)control character
upperctype_base::maskunspecified (unique bits)uppercase letter
lowerctype_base::maskunspecified (unique bits)lowercase letter
alphactype_base::maskunspecified (unique bits)alphabetic character
digitctype_base::maskunspecified (unique bits)decimal digit
punctctype_base::maskunspecified (unique bits)punctuation character
xdigitctype_base::maskunspecified (unique bits)hexadecimal digit
alnumctype_base::maskalpha|digitalpha-numeric character
graphctype_base::maskalnum|punctcharacter with graphic representation
member constanttypevaluedescription
spacectype_base::maskunspecified (unique bits)white-space character
printctype_base::maskunspecified (unique bits)printable character
cntrlctype_base::maskunspecified (unique bits)control character
upperctype_base::maskunspecified (unique bits)uppercase letter
lowerctype_base::maskunspecified (unique bits)lowercase letter
alphactype_base::maskunspecified (unique bits)alphabetic character
digitctype_base::maskunspecified (unique bits)decimal digit
punctctype_base::maskunspecified (unique bits)punctuation character
xdigitctype_base::maskunspecified (unique bits)hexadecimal digit
blankctype_base::maskunspecified (unique bits)blank character
alnumctype_base::maskalpha|digitalpha-numeric character
graphctype_base::maskalnum|punctcharacter with graphic representation
See <cctype> for details on how ASCII characters are classified with respect to these categories.

The class also contains a public static constant of type locale::id , that uniquely identifies facets with ctype semantics.

Public member functions

(constructor)
ctype constructor (public member function)

Character classification

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)

Character transformation

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)

Virtual protected member functions

The class defines the virtual protected members which implement the behavior by default of their respective public member functions:
do_is
Classify characters [virtual] (protected virtual member function)
do_scan_is
Return first character in category [virtual] (protected virtual member function)
do_scan_not
Return first character not in category [virtual] (protected virtual member function)
do_toupper
Convert to uppercase [virtual] (protected virtual member function)
do_tolower
Convert to lowercase [virtual] (protected virtual member function)
do_widen
Widen character(s) [virtual] (protected virtual member function)
do_narrow
Narrow character(s) [virtual] (protected virtual member function)

Along with the class destructor:
(destructor)
ctype destructor (protected member function)

Specializations

At least the following specializations of this template are provided in all library implementations:
specialization
ctype<char>
ctype<wchar_t>

Particular specialization: ctype<char>

On the char specialization, some of the member functions are implemented inline instead of calling their do_ counterparts (this is the case for members is , scan_is and scan_not ).

It has a different constructor, and keeps an internal table of elements of type ctype::mask with 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.

The size of this table is indicated by an additional static public member constant:
member constanttypevaluedescription
table_sizeconst size_t implementation-specific (at least 256)The size of the table
This specialization contains two additional protected members:
table
Get category table (public member function)
classic_table
Get classic table (public static member function)
This specialization contains two additional public members:
table
Get category table (public member function)
classic_table
Get classic table (public static member function)

Note that do_is , do_scan_is and do_scan_not are not members of the char specialization.

AltStyle によって変換されたページ (->オリジナル) /