25 Localization library [localization]

25.4 Standard locale categories [locale.categories]

25.4.1 The ctype category [category.ctype]

25.4.1.3 ctype specializations [facet.ctype.special]

namespace std {
  template <>
    class ctype<char> : public locale::facet, public ctype_base {
    public:
      using char_type = char;

      explicit ctype(const mask* tab = 0, bool del = false,
                     size_t refs = 0);

      bool is(mask m, char c) const;
      const char* is(const char* low, const char* high, mask* vec) const;
      const char* scan_is (mask m,
                           const char* low, const char* high) const;
      const char* scan_not(mask m,
                           const char* low, const char* high) const;

      char        toupper(char c) const;
      const char* toupper(char* low, const char* high) const;
      char        tolower(char c) const;
      const char* tolower(char* low, const char* high) const;

      char  widen(char c) const;
      const char* widen(const char* low, const char* high, char* to) const;
      char  narrow(char c, char dfault) const;
      const char* narrow(const char* low, const char* high, char dfault,
                         char* to) const;

      static locale::id id;
      static const size_t table_size = implementation-defined;

      const mask* table() const noexcept;
      static const mask* classic_table() noexcept;

    protected:
      ~ctype();
      virtual char        do_toupper(char c) const;
      virtual const char* do_toupper(char* low, const char* high) const;
      virtual char        do_tolower(char c) const;
      virtual const char* do_tolower(char* low, const char* high) const;

      virtual char        do_widen(char c) const;
      virtual const char* do_widen(const char* low,
                                   const char* high,
                                   char* to) const;
      virtual char        do_narrow(char c, char dfault) const;
      virtual const char* do_narrow(const char* low,
                                    const char* high,
                                    char dfault, char* to) const;
    };
}

A specialization ctype<char> is provided so that the member functions on type char can be implemented inline.235 The implementation-defined value of member table_­size is at least 256.

Only the char (not unsigned char and signed char) form is provided. The specialization is specified in the standard, and not left as an implementation detail, because it affects the derivation interface for ctype<char>.

25.4.1.3.1 ctype<char> destructor [facet.ctype.char.dtor]

~ctype();

Effects: If the constructor's first argument was nonzero, and its second argument was true, does delete [] table().

25.4.1.3.2 ctype<char> members [facet.ctype.char.members]

In the following member descriptions, for unsigned char values v where v >= table_­size, table()[v] is assumed to have an implementation-specific value (possibly different for each such value v) without performing the array lookup.

explicit ctype(const mask* tbl = 0, bool del = false, size_t refs = 0);

Requires: tbl either 0 or an array of at least table_­size elements.

Effects: Passes its refs argument to its base class constructor.

bool is(mask m, char c) const; const char* is(const char* low, const char* high, mask* vec) const;

Effects: The second form, for all *p in the range [low, high), assigns into vec[p - low] the value table()[(unsigned char)*p].

Returns: The first form returns table()[(unsigned char)c] & m; the second form returns high.

const char* scan_is(mask m, const char* low, const char* high) const;

Returns: The smallest p in the range [low, high) such that

table()[(unsigned char) *p] & m

is true.

const char* scan_not(mask m, const char* low, const char* high) const;

Returns: The smallest p in the range [low, high) such that

table()[(unsigned char) *p] & m

is false.

char toupper(char c) const; const char* toupper(char* low, const char* high) const;

Returns: do_­toupper(c) or do_­toupper(low, high), respectively.

char tolower(char c) const; const char* tolower(char* low, const char* high) const;

Returns: do_­tolower(c) or do_­tolower(low, high), respectively.

char widen(char c) const; const char* widen(const char* low, const char* high, char* to) const;

Returns: do_­widen(c) or do_­widen(low, high, to), respectively.

char narrow(char c, char dfault) const; const char* narrow(const char* low, const char* high, char dfault, char* to) const;

Returns: do_­narrow(c, dfault) or do_­narrow(low, high, dfault, to), respectively.

const mask* table() const noexcept;

Returns: The first constructor argument, if it was nonzero, otherwise classic_­table().

25.4.1.3.3 ctype<char> static members [facet.ctype.char.statics]

static const mask* classic_table() noexcept;

Returns: A pointer to the initial element of an array of size table_­size which represents the classifications of characters in the "C" locale.

25.4.1.3.4 ctype<char> virtual functions [facet.ctype.char.virtuals]

char        do_toupper(char) const;
const char* do_toupper(char* low, const char* high) const;
char        do_tolower(char) const;
const char* do_tolower(char* low, const char* high) const;

virtual char        do_widen(char c) const;
virtual const char* do_widen(const char* low,
                             const char* high,
                             char* to) const;
virtual char        do_narrow(char c, char dfault) const;
virtual const char* do_narrow(const char* low,
                              const char* high,
                              char dfault, char* to) const;

These functions are described identically as those members of the same name in the ctype class template.