Name

ctype<char> class — Facet for classifying narrow characters

Synopsis

template <>
class ctype<char> : public locale::facet, public ctype_base
{
  ...
public:
  explicit ctype(const mask* tab = 0, bool del = false, size_t refs = 0);
  static const size_t table_size =  . . . ;
  inline bool is(mask m, char c) const;
  inline const char* is(const char* low, const char* high, mask* vec) const;
  inline const char* scan_is(mask m, const char* low, const char* high) const;
  inline const char* scan_not(mask m, const char* low, const char* high) const;
protected:
  virtual ~ctype(  );
  inline const mask* table(  ) const throw(  );
  inline static const mask* classic_table(  ) throw(  );
};

The ctype<> class template is specialized for type char (but not signed char or unsigned char) so the member functions can be implemented as inline functions. The standard requires the implementation to have the protected member functions table and classic_table. Each of these functions returns an array of mask values indexed by characters cast to unsigned char. The number of elements in a table must be at least table_size, which is an implementation-defined constant value.

The following are the key member functions:

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

Initializes the table( ) pointer with tab. If tab is a null pointer, table( ) is set to classic_table( ). If tab is not null, and del is true, the ctype object owns the table, and when the ctype destructor is called, it will delete the table. ...

Get C++ In a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.