ctype

char_type · ctype · do_is · do_narrow · do_scan_is · do_scan_not · do_tolower · do_toupper · do_widen · is · narrow · scan_is · scan_not · tolower · toupper · widen

template<class E>
    class ctype : public locale::facet, public ctype_base {
public:
    typedef E char_type;
    explicit ctype(size_t refs = 0);
    bool is(mask msk, E ch) const;
    const E *is(const E *first, const E *last, mask *dst) const;
    const E *scan_is(mask msk, const E *first, const E *last) const;
    const E *scan_not(mask msk, const E *first, const E *last) const;
    E toupper(E ch) const;
    const E *toupper(E *first, E *last) const;
    E tolower(E ch) const;
    const E *tolower(E *first, E *last) const;
    E widen(char ch) const;
    const char *widen(char *first, char *last, E *dst) const;
    char narrow(E ch, char dflt) const;
    const E *narrow(const E *first, const E *last,
        char dflt, char *dst) const;
    static locale::id id;
protected:
    ~ctype();
    virtual bool do_is(mask msk, E ch) const;
    virtual const E *do_is(const E *first, const E *last,
        mask *dst) const;
    virtual const E *do_scan_is(mask msk, const E *first,
        const E *last) const;
    virtual const E *do_scan_not(mask msk, const E *first,
        const E *last) const;
    virtual E do_toupper(E ch) const;
    virtual const E *do_toupper(E *first, E *last) const;
    virtual E do_tolower(E ch) const;
    virtual const E *do_tolower(E *first, E *last) const;
    virtual E do_widen(char ch) const;
    virtual const char *do_widen(char *first, char *last, E *dst) const;
    virtual char do_narrow(E ch, char dflt) const;
    virtual const E *do_narrow(const E *first, const E *last,
        char dflt, char *dst) const;
    };

The template class describes an object that can serve as a locale facet, to characterize various properties of a "character" (element) of type E. Such a facet also converts between sequences of E elements and sequences of char.

An object of class ctype<E> 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 when the ctype<E> object is destroyed.

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.

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

In this implementation, other specializations of template class ctype<E>:

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