Compartilhar via


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.

template <class CharType>
   class ctype : public ctype_base;

Parameters

  • CharType
    The type used within a program to encode characters.

Remarks

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>.

Constructors

ctype

Constructor for objects of class ctype that serve as locale facets for characters.

Typedefs

char_type

A type that describes a character used by a locale.

Member Functions

do_is

A virtual function called to test whether a single character has a particular attribute, or classify the attributes of each character in a range and stores them in an array.

do_narrow

A virtual function called to convert a character of type CharType used by a locale to the corresponding character of type char in the native character set.

do_scan_is

A virtual function called to locate the first character in a range that matches a specified mask.

do_scan_not

A virtual function called to locate the first character in a range that does not match a specified mask.

do_tolower

A virtual function called to convert a character or a range of characters to their lower case.

do_toupper

A virtual function called to convert a character or a range of characters to upper case.

do_widen

A virtual function called to converts a character of type char in the native character set to the corresponding character of type CharType used by a locale.

is

Tests whether a single character has a particular attribute, or classifies the attributes of each character in a range and stores them in an array.

narrow

Converts a character of type CharType used by a locale to the corresponding character of type char in the native character set.

scan_is

Locates the first character in a range that matches a specified mask.

scan_not

Locates the first character in a range that does not match a specified mask.

tolower

Converts a character or a range of characters to lower case.

toupper

Converts a character or a range of characters to upper case.

widen

Converts a character of type char in the native character set to the corresponding character of type CharType used by a locale.

Requirements

Header: <locale>

Namespace: std

See Also

Reference

<locale>

Thread Safety in the C++ Standard Library