Namespaces
Variants
Views
Actions

std::ctype_byname

From cppreference.com
< cpp‎ | locale
Revision as of 03:27, 23 April 2013 by P12 (Talk | contribs)

Template:ddcl list begin <tr class="t-dsc-header">

<td>
Defined in header <locale>
</td>

<td></td> <td></td> <tr class="t-dcl-sep"><td></td><td></td><td></td></tr>

<tr class="t-dcl ">

<td class="t-dcl-nopad">
template< class CharT >
class ctype_byname : public std::ctype<CharT>;
</td>

<td class="t-dcl-nopad"> </td> <td class="t-dcl-nopad"> </td> </tr> Template:ddcl list end

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

Two specializations are provided by the standard library

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

Contents

Member types

Member type Definition
mask ctype<CharT>::mask

Member functions

constructs a new ctype_byname facet
(public member function)
destructs a ctype_byname facet
(protected member function)

Inherited from std::ctype<CharT>

Member types

Member type Definition
char_type CharT

Member objects

Member name Type
static std::locale::id id
[static]
id of the locale
(public static member constant)
if CharT is char, the following member of std::ctype<char> is inherited
static const std::size_t table_size
[static]
size of the classification table, at least 256
(public static member constant)

Member functions

invokes do_is
(public member function of std::ctype) [edit]
invokes do_scan_is
(public member function of std::ctype) [edit]
invokes do_scan_not
(public member function of std::ctype) [edit]
invokes do_toupper
(public member function of std::ctype) [edit]
invokes do_tolower
(public member function of std::ctype) [edit]
invokes do_widen
(public member function of std::ctype) [edit]
invokes do_narrow
(public member function of std::ctype) [edit]
if CharT is char, the following members of std::ctype<char> are inherited
obtains the character classification table
(public member function of std::ctype<char>) [edit]
obtains the "C" locale character classification table
(public static member function of std::ctype<char>) [edit]

Protected member functions

[virtual]
converts a character or characters to uppercase
(virtual protected member function of std::ctype) [edit]
[virtual]
converts a character or characters to lowercase
(virtual protected member function of std::ctype) [edit]
[virtual]
converts a character or characters from char to charT
(virtual protected member function of std::ctype) [edit]
[virtual]
converts a character or characters from charT to char
(virtual protected member function of std::ctype) [edit]
if CharT is char, the following members of std::ctype are NOT inherited
[virtual]
classifies a character or a character sequence
(virtual protected member function of std::ctype) [edit]
[virtual]
locates the first character in a sequence that conforms to given classification
(virtual protected member function of std::ctype) [edit]
[virtual]
locates the first character in a sequence that fails given classification
(virtual protected member function of std::ctype) [edit]

Inherited from std::ctype_base

Member types

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

Member constants

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

Example

#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

See also

Template:cpp/locale/dcl list ctypeTemplate:cpp/locale/dcl list ctype char