[facet.ctype.special]

# 28 Text processing library [[text]](./#text)

## 28.3 Localization library [[localization]](localization#facet.ctype.special)

### 28.3.4 Standard locale categories [[locale.categories]](locale.categories#facet.ctype.special)

#### 28.3.4.2 The ctype category [[category.ctype]](category.ctype#facet.ctype.special)

#### 28.3.4.2.4 ctype<char> specialization [facet.ctype.special]

#### [28.3.4.2.4.1](#general) General [[facet.ctype.special.general]](facet.ctype.special.general)

[ð](#lib:ctype%3cchar%3e)

namespace std {template<>class ctype<char> : public locale::facet, public ctype_base {public:using char_type = char; explicit ctype(const mask* tab = nullptr, 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; };}

[1](#general-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1748)

A specialization ctype<char> is provided
so that the member functions on type char can be implemented inline[.](#general-1.sentence-1)[219](#footnote-219 "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>.")

The implementation-defined value of
member table_size is at least 256[.](#general-1.sentence-2)

[219)](#footnote-219)[219)](#footnoteref-219)

Only the char (not unsigned char and signed char)
form is provided[.](#footnote-219.sentence-1)

The specialization is specified in the standard,
and not left as an implementation detail,
because it affects the derivation interface for ctype<char>[.](#footnote-219.sentence-2)

#### [28.3.4.2.4.2](#facet.ctype.char.dtor) Destructor [[facet.ctype.char.dtor]](facet.ctype.char.dtor)

[ð](#lib:ctype%3cchar%3e,destructor)

`~ctype();
`

[1](#facet.ctype.char.dtor-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1769)

*Effects*: If the constructor's first argument was nonzero, and
its second argument was true,
does delete [] table()[.](#facet.ctype.char.dtor-1.sentence-1)

#### [28.3.4.2.4.3](#facet.ctype.char.members) Members [[facet.ctype.char.members]](facet.ctype.char.members)

[1](#facet.ctype.char.members-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1778)

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[.](#facet.ctype.char.members-1.sentence-1)

[ð](#lib:ctype%3cchar%3e,constructor)

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

[2](#facet.ctype.char.members-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1792)

*Preconditions*: Either tbl == nullptr is true or
[tbl, tbl + table_size) is a valid range[.](#facet.ctype.char.members-2.sentence-1)

[3](#facet.ctype.char.members-3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1797)

*Effects*: Passes its refs argument to its base class constructor[.](#facet.ctype.char.members-3.sentence-1)

[ð](#lib:ctype%3cchar%3e,is)

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

[4](#facet.ctype.char.members-4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1809)

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

[5](#facet.ctype.char.members-5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1814)

*Returns*: The first form returns table()[(unsigned char)c] & m;
the second form returns high[.](#facet.ctype.char.members-5.sentence-1)

[ð](#lib:ctype%3cchar%3e,scan_is)

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

[6](#facet.ctype.char.members-6)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1826)

*Returns*: The smallest p in the range [low, high) such thattable()[(unsigned char) *p] & m is true[.](#facet.ctype.char.members-6.sentence-1)

[ð](#lib:ctype%3cchar%3e,scan_not)

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

[7](#facet.ctype.char.members-7)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1841)

*Returns*: The smallest p in the range [low, high) such thattable()[(unsigned char) *p] & m is false[.](#facet.ctype.char.members-7.sentence-1)

[ð](#lib:ctype%3cchar%3e,toupper)

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

[8](#facet.ctype.char.members-8)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1857)

*Returns*: do_toupper(c) or do_toupper(low, high), respectively[.](#facet.ctype.char.members-8.sentence-1)

[ð](#lib:ctype%3cchar%3e,tolower)

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

[9](#facet.ctype.char.members-9)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1869)

*Returns*: do_tolower(c) or do_tolower(low, high), respectively[.](#facet.ctype.char.members-9.sentence-1)

[ð](#lib:ctype%3cchar%3e,widen)

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

[10](#facet.ctype.char.members-10)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1881)

*Returns*: do_widen(c) ordo_widen(low, high, to), respectively[.](#facet.ctype.char.members-10.sentence-1)

[ð](#lib:ctype%3cchar%3e,narrow)

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

[11](#facet.ctype.char.members-11)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1895)

*Returns*: do_narrow(c, dfault) ordo_narrow(low, high, dfault, to),
respectively[.](#facet.ctype.char.members-11.sentence-1)

[ð](#lib:ctype%3cchar%3e,table)

`const mask* table() const noexcept;
`

[12](#facet.ctype.char.members-12)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1910)

*Returns*: The first constructor argument, if it was nonzero,
otherwise classic_table()[.](#facet.ctype.char.members-12.sentence-1)

#### [28.3.4.2.4.4](#facet.ctype.char.statics) Static members [[facet.ctype.char.statics]](facet.ctype.char.statics)

[ð](#lib:ctype%3cchar%3e,classic_table)

`static const mask* classic_table() noexcept;
`

[1](#facet.ctype.char.statics-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1924)

*Returns*: A pointer to the initial element of an array of size table_size which represents the classifications of characters in the "C" locale[.](#facet.ctype.char.statics-1.sentence-1)

#### [28.3.4.2.4.5](#facet.ctype.char.virtuals) Virtual functions [[facet.ctype.char.virtuals]](facet.ctype.char.virtuals)

[ð](#lib:ctype%3cchar%3e,do_toupper)

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;

[1](#facet.ctype.char.virtuals-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1949)

These functions are described identically as those members of the same name
in the ctype class template ([[locale.ctype.members]](locale.ctype.members "28.3.4.2.2.2 ctype members"))[.](#facet.ctype.char.virtuals-1.sentence-1)
