Scroll to navigation

std::ctype_byname(3) C++ Standard Libary std::ctype_byname(3)

NAME

std::ctype_byname - std::ctype_byname

Synopsis

Defined in header <locale> template< class CharT > class ctype_byname : public std::ctype<CharT>;

std::ctype_byname is a std::ctype facet which encapsulates character classification rules of the locale specified at its construction.

Specializations

The standard library is guaranteed to provide the following specializations:

Defined in header <locale> std::ctype_byname<char> provides narrow character classification (uses table lookup for
character classification) std::ctype_byname<wchar_t> provides wide character classification


Nested types

Type Definition mask typename std::ctype<CharT>::mask

Member functions

constructor constructs a new ctype_byname facet
(public member function) destructor destroys a ctype_byname facet
(protected member function)

std::ctype_byname::ctype_byname

explicit ctype_byname( const char* name, std::size_t refs = 0 ); explicit ctype_byname( const std::string& name, std::size_t refs = 0 ); (since C++11)

Constructs a new std::ctype_byname facet for a locale with name.

refs is used for resource management: if refs == 0, the implementation destroys the facet, when the last std::locale object holding it is destroyed. Otherwise, the object is not destroyed.

Parameters

name - the name of the locale refs - the number of references that link to the facet

std::ctype_byname::~ctype_byname

protected: ~ctype_byname();

Destroys the facet.

Inherited from std::ctype<CharT> (only if CharT is not char)


Nested types

Type Definition char_type CharT


Data members

Member Description std::locale::id id [static] the identifier of the facet

Member functions

is invokes do_is
(public member function of std::ctype<CharT>) scan_is invokes do_scan_is
(public member function of std::ctype<CharT>) scan_not invokes do_scan_not
(public member function of std::ctype<CharT>) toupper invokes do_toupper
(public member function of std::ctype<CharT>) tolower invokes do_tolower
(public member function of std::ctype<CharT>) widen invokes do_widen
(public member function of std::ctype<CharT>) narrow invokes do_narrow
(public member function of std::ctype<CharT>)

Protected member functions

do_toupper converts a character or characters to uppercase [virtual] (virtual protected member function of std::ctype<CharT>) do_tolower converts a character or characters to lowercase [virtual] (virtual protected member function of std::ctype<CharT>) do_widen converts a character or characters from char to CharT [virtual] (virtual protected member function of std::ctype<CharT>) do_narrow converts a character or characters from CharT to char [virtual] (virtual protected member function of std::ctype<CharT>) do_is classifies a character or a character sequence [virtual] (virtual protected member function of std::ctype<CharT>) do_scan_is locates the first character in a sequence that conforms to given [virtual] classification
(virtual protected member function of std::ctype<CharT>) do_scan_not locates the first character in a sequence that fails given classification [virtual] (virtual protected member function of std::ctype<CharT>)

Inherited from std::ctype<char> (only if CharT is char)


Nested types

Type Definition char_type char


Data members

Member Description std::locale::id id [static] the identifier of the facet const std::size_t table_size [static] size of the classification table, at least 256

Member functions

table obtains the character classification table
(public member function of std::ctype<char>) classic_table obtains the "C" locale character classification table [static] (public static member function of std::ctype<char>)
classifies a character or a character sequence, using the classification is table
(public member function of std::ctype<char>)
locates the first character in a sequence that conforms to given scan_is classification, using the classification table
(public member function of std::ctype<char>)
locates the first character in a sequence that fails given classification, scan_not using the classification table
(public member function of std::ctype<char>) toupper invokes do_toupper
(public member function of std::ctype<CharT>) tolower invokes do_tolower
(public member function of std::ctype<CharT>) widen invokes do_widen
(public member function of std::ctype<CharT>) narrow invokes do_narrow
(public member function of std::ctype<CharT>)

Protected member functions

do_toupper converts a character or characters to uppercase [virtual] (virtual protected member function of std::ctype<CharT>) do_tolower converts a character or characters to lowercase [virtual] (virtual protected member function of std::ctype<CharT>) do_widen converts a character or characters from char to CharT [virtual] (virtual protected member function of std::ctype<CharT>) do_narrow converts a character or characters from CharT to char [virtual] (virtual protected member function of std::ctype<CharT>)

Inherited from std::ctype_base


Nested types

Type Definition mask unspecified BitmaskType type (enumeration, integer type, or bitset)

Member constants

space the value of mask identifying whitespace character classification [static] (public static member constant) print the value of mask identifying printable character classification [static] (public static member constant) cntrl the value of mask identifying control character classification [static] (public static member constant) upper the value of mask identifying uppercase character classification [static] (public static member constant) lower the value of mask identifying lowercase character classification [static] (public static member constant) alpha the value of mask identifying alphabetic character classification [static] (public static member constant) digit the value of mask identifying digit character classification [static] (public static member constant) punct the value of mask identifying punctuation character classification [static] (public static member constant) xdigit the value of mask identifying hexadecimal digit character classification [static] (public static member constant) blank the value of mask identifying blank character classification [static] (C++11) (public static member constant) alnum alpha | digit [static] (public static member constant) graph alnum | punct [static] (public static member constant)

Notes

std::ctype_byname<char> was incorrectly declared as an explicit specialization in the synopsis of <locale>, and the declaration was removed by the resolution of LWG issue 1298, but it remains a required specialization, just like std::ctype_byname<wchar_t>.

Example

// Run this code

#include <iostream> #include <locale>

int main() {
wchar_t c = L'\u00de'; // capital letter thorn


std::locale loc("C");


std::cout << "isupper('Þ', C locale) returned "
<< std::boolalpha << std::isupper(c, loc) << '\n';


loc = std::locale(loc, new std::ctype_byname<wchar_t>("en_US.utf8"));


std::cout << "isupper('Þ', C locale with Unicode ctype) returned "
<< std::boolalpha << std::isupper(c, loc) << '\n'; }

Output:

isupper('Þ', C locale) returned false isupper('Þ', C locale with Unicode ctype) returned true


Defect reports

The following behavior-changing defect reports were applied retroactively to previously published C++ standards.


DR Applied to Behavior as published Correct behavior
the definition of the explicit specialization LWG 16 C++98 std::ctype_byname<char> corrected
misspecified the name and parameter list of do_narrow LWG 616 C++98 the typename disambiguator was missing in the added
definition of mask

See also

ctype defines character classification tables
(class template) ctype<char> specialization of std::ctype for type char
(class template specialization)

2026.11.10 http://cppreference.com