Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::char_traits<char>::eq/lt,std::char_traits<wchar_t>::eq/lt,std::char_traits<char8_t>::eq/lt,std::char_traits<char16_t>::eq/lt,std::char_traits<char32_t>::eq/lt

      From cppreference.com
      <cpp‎ |string‎ |char traits
       
       
       
       
      staticbool eq( char_type a, char_type b);
      (1)(constexpr since C++11)
      (noexcept since C++11)
      staticbool lt( char_type a, char_type b);
      (2)(constexpr since C++11)
      (noexcept since C++11)

      Compares two characters.

      1) Comparesa andb for equality, behaves identically to
      • static_cast<unsignedchar>(a)==static_cast<unsignedchar>(b), ifchar_type ischar,
      • a== b otherwise.
      2) Comparesa andb in such a way that they are totally ordered, behaves identically to
      • static_cast<unsignedchar>(a)<static_cast<unsignedchar>(b), ifchar_type ischar,
      • a< b otherwise.

      SeeCharTraits for the general requirements on character traits forX::eq andX::lt.

      Contents

      [edit]Parameters

      a, b - character values to compare

      [edit]Return value

      1)true ifa andb are equal,false otherwise.
      2)true ifa is less thanb,false otherwise.

      [edit]Complexity

      Constant.

      [edit]Defect reports

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

      DRApplied toBehavior as publishedCorrect behavior
      LWG 467C++98forstd::char_traits<char>, the semantics ofeq() andlt()
      are the same as the built-in== and< onchar respectively[1]
      changed to built-in== and
      < onunsignedchar
      1. Most implementations callstd::memcmp() for efficiency, which interprets the data as arrays ofunsignedchar. Ifcharis signed on such implementations,std::char_traits<char> fails to satisfy the requirements ofCharTraits.
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/string/char_traits/cmp&oldid=171371"

      [8]ページ先頭

      ©2009-2025 Movatter.jp