• Class / Function / Type

      std::
    • Header file

      <>
    • Other / All

    最終更新日時(UTC):
    が更新

    履歴 編集

    function
    <string>

    std::char_traits::eq_int_type

    static bool eq_int_type(const int_type& c1, const int_type& c2);      // C++03
    static constexpr bool eq_int_type(int_type c1, int_type c2) noexcept; // C++11
    

    概要

    数値の等値比較を行う。

    戻り値

    全ての文字cdに対しては、eq(c, d)eq_int_type(to_int_type(c), to_int_type(d))は等価となる。

    文字以外として、c1c2がどちらもeofであるならtrue、それ以外はfalseを返す。

    計算量

    定数時間

    #include <iostream>
    #include <string>
    
    int main()
    {
      if (std::char_traits<char>::eq_int_type(1, 1)) {
        std::cout << "equal" << std::endl;
      }
      else {
        std::cout << "not equal" << std::endl;
      }
    }
    

    出力例

    equal
    

    参照