Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::ctype_byname

      From cppreference.com
      <cpp‎ |locale
       
       
       
      Localization library
       
      Defined in header<locale>
      template<class CharT>
      class ctype_byname:publicstd::ctype<CharT>;

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

      Contents

      [edit]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

      [edit]Nested types

      Type Definition
      masktypenamestd::ctype<CharT>::mask

      [edit]Member functions

      (constructor)
      constructs a newctype_byname facet
      (public member function)[edit]
      (destructor)
      destroys actype_byname facet
      (protected member function)[edit]
      [edit]

      std::ctype_byname::ctype_byname

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

      Constructs a newstd::ctype_byname facet for a locale withname.

      refs is used for resource management: ifrefs==0, the implementation destroys the facet, when the laststd::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
      [edit]

      std::ctype_byname::~ctype_byname

      protected:
      ~ctype_byname();

      Destroys the facet.

      Inherited fromstd::ctype<CharT>(only ifCharT is notchar)

      Nested types

      Type Definition
      char_typeCharT

      Data members

      Member Description
      std::locale::idid[static] the identifier of thefacet

      Member functions

      invokesdo_is
      (public member function ofstd::ctype<CharT>)[edit]
      invokesdo_scan_is
      (public member function ofstd::ctype<CharT>)[edit]
      invokesdo_scan_not
      (public member function ofstd::ctype<CharT>)[edit]
      invokesdo_toupper
      (public member function ofstd::ctype<CharT>)[edit]
      invokesdo_tolower
      (public member function ofstd::ctype<CharT>)[edit]
      invokesdo_widen
      (public member function ofstd::ctype<CharT>)[edit]
      invokesdo_narrow
      (public member function ofstd::ctype<CharT>)[edit]

      Protected member functions

      [virtual]
      converts a character or characters to uppercase
      (virtual protected member function ofstd::ctype<CharT>)[edit]
      [virtual]
      converts a character or characters to lowercase
      (virtual protected member function ofstd::ctype<CharT>)[edit]
      [virtual]
      converts a character or characters fromchar toCharT
      (virtual protected member function ofstd::ctype<CharT>)[edit]
      [virtual]
      converts a character or characters fromCharT tochar
      (virtual protected member function ofstd::ctype<CharT>)[edit]
      [virtual]
      classifies a character or a character sequence
      (virtual protected member function ofstd::ctype<CharT>)[edit]
      [virtual]
      locates the first character in a sequence that conforms to given classification
      (virtual protected member function ofstd::ctype<CharT>)[edit]
      [virtual]
      locates the first character in a sequence that fails given classification
      (virtual protected member function ofstd::ctype<CharT>)[edit]

      Inherited fromstd::ctype<char>(only ifCharT ischar)

      Nested types

      Type Definition
      char_typechar

      Data members

      Member Description
      std::locale::idid[static] the identifier of thefacet
      conststd::size_ttable_size[static] size of the classification table, at least 256

      Member functions

      obtains the character classification table
      (public member function ofstd::ctype<char>)[edit]
      obtains the "C" locale character classification table
      (public static member function ofstd::ctype<char>)[edit]
      classifies a character or a character sequence, using the classification table
      (public member function ofstd::ctype<char>)[edit]
      locates the first character in a sequence that conforms to given classification, using the classification table
      (public member function ofstd::ctype<char>)[edit]
      locates the first character in a sequence that fails given classification, using the classification table
      (public member function ofstd::ctype<char>)[edit]
      invokesdo_toupper
      (public member function ofstd::ctype<CharT>)[edit]
      invokesdo_tolower
      (public member function ofstd::ctype<CharT>)[edit]
      invokesdo_widen
      (public member function ofstd::ctype<CharT>)[edit]
      invokesdo_narrow
      (public member function ofstd::ctype<CharT>)[edit]

      Protected member functions

      [virtual]
      converts a character or characters to uppercase
      (virtual protected member function ofstd::ctype<CharT>)[edit]
      [virtual]
      converts a character or characters to lowercase
      (virtual protected member function ofstd::ctype<CharT>)[edit]
      [virtual]
      converts a character or characters fromchar toCharT
      (virtual protected member function ofstd::ctype<CharT>)[edit]
      [virtual]
      converts a character or characters fromCharT tochar
      (virtual protected member function ofstd::ctype<CharT>)[edit]

      Inherited fromstd::ctype_base

      Nested types

      Type Definition
      mask unspecifiedBitmaskType type (enumeration, integer type, or bitset)

      Member constants

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

      [edit]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 ofLWG issue 1298, but it remains a required specialization, just likestd::ctype_byname<wchar_t>.

      [edit]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 falseisupper('Þ', C locale with Unicode ctype) returned true

      [edit]Defect reports

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

      DRApplied toBehavior as publishedCorrect behavior
      LWG 16C++98the definition of the explicit specializationstd::ctype_byname<char>
      misspecified the name and parameter list ofdo_narrow
      corrected
      LWG 616C++98thetypename disambiguator was missing in the definition ofmaskadded

      [edit]See also

      defines character classification tables
      (class template)[edit]
      specialization ofstd::ctype for typechar
      (class template specialization)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/locale/ctype_byname&oldid=177977"

      [8]ページ先頭

      ©2009-2025 Movatter.jp