Share via


ctype<char> Class

The class is an explicit specialization of template class ctype<CharType> to type char, describing an object that can serve as a locale facet to characterize various properties of a character of type char.

template<> class ctype<char>
    : public ctype_base
{
public:
    typedef char _Elem;
    typedef _Elem char_type;
    bool is(
        mask _Maskval,
        _Elem _Ch
    ) const;
    const _Elem* is(
        const _Elem *_First,
        const _Elem *_Last,
        mask *_Dest
    ) const;
    const _Elem* scan_is(
        mask _Maskval,
        const _Elem *_First,
        const _Elem *_Last
    ) const;
    const _Elem* scan_not(
        mask _Maskval,
        const _Elem *_First,
        const _Elem *_Last
    ) const;
    _Elem tolower(
        _Elem _Ch
    ) const;
    const _Elem* tolower(
        _Elem *_First,
        const _Elem *_Last
    ) const;
    _Elem toupper(
        _Elem _Ch
    ) const;
    const _Elem* toupper(
        _Elem *_First,
        const _Elem *_Last
    ) const;
    _Elem widen(
        char _Byte
    ) const;
    const _Elem* widen(
        const char *_First,
        const char *_Last,
        _Elem *_Dest
    ) const;
    const _Elem* _Widen_s(
        const char *_First,
        const char *_Last,
        _Elem *_Dest,
        size_t _Dest_size
    ) const;
    _Elem narrow(
        _Elem _Ch,
        char _Dflt = '\0'
    ) const;
    const _Elem* narrow(
        const _Elem *_First,
        const _Elem *_Last,
        char _Dflt,
        char *_Dest
    ) const;
    const _Elem* _Narrow_s(
        const _Elem *_First,
        const _Elem *_Last,
        char _Dflt,
        char *_Dest,
        size_t _Dest_size
    ) const;
    static locale::id& id;
    explicit  ctype(
        const mask *_Table = 0,
        bool _Deletetable = false,
        size_t _Refs = 0);
protected:
    virtual  ~ctype();
    //other protected members
};

Remarks

The explicit specialization differs from the template class in several ways:

  • An object of class ctype<char> stores a pointer to the first element of a ctype mask table, an array of UCHAR_MAX + 1 elements of type ctype_base::mask. It also stores a Boolean object that indicates whether the array should be deleted (using operator delete[]) when the ctype<Elem> object is destroyed.

  • Its sole public constructor lets you specify tab, the ctype mask table, and del, the Boolean object that is true if the array should be deleted when the ctype<char> object is destroyed, as well as the reference-count parameter refs.

  • The protected member function table returns the stored ctype mask table.

  • The static member object table_size specifies the minimum number of elements in a ctype mask table.

  • The protected static member function classic_table( returns the ctype mask table appropriate to the "C" locale.

  • There are no protected virtual member functions do_is, do_scan_is, or do_scan_not. The corresponding public member functions perform the equivalent operations themselves.

The member functions do_narrow and do_widen copy elements unaltered.

Requirements

Header: <locale>

Namespace: std

See Also

Reference

facet Class

ctype_base Class

Thread Safety in the Standard C++ Library