Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

ctype Class

A class that provides a facet that is used to classify characters, convert from upper and lower cases, and convert between the native character set and that set used by the locale.

For a list of all members of this type, see ctype Members.

template <class CharType> 
class ctype : public ctype_base


The type used within a program to encode characters.

As with any locale facet, the static object ID has an initial stored value of zero. The first attempt to access its stored value stores a unique positive value in id. Classification criteria are provided a nested bitmask type in the base class ctype_base.

The Standard C++ Library defines two explicit specializations of this template class:

  • ctype<char>, an explicit specialization whose differences are described separately.

  • ctype<wchar_t>, which treats elements as wide characters.

Other specializations of template class ctype<CharType>:

  • Convert a value ch of type CharType to a value of type char with the expression (char)ch.

  • Convert a value byte of type char to a value of type CharType with the expression CharType (byte).

All other operations are performed on char values in the same way as for the explicit specialization ctype<char>.

Header: <locale>

Namespace: std

Community Additions

© 2015 Microsoft