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

履歴 編集

function
<system_error>

std::error_category::operator<=>(C++20)

strong_ordering operator<=>(const error_category& rhs) const noexcept; // (1) C++11

概要

error_categoryオブジェクトの三方比較を行う。

戻り値

return compare_three_way()(this, &rhs);

例外

投げない

備考

  • この演算子により、以下の演算子が使用可能になる (C++20):
    • operator<
    • operator<=
    • operator>
    • operator>=

#include <iostream>
#include <system_error>

int main()
{
  const std::error_category& a = std::generic_category();
  const std::error_category& b = std::generic_category();
  const std::error_category& c = std::system_category();

  std::cout << std::boolalpha;

  std::cout << ((a <=> b) == 0) << std::endl;
  std::cout << (a < c) << std::endl;
  std::cout << (a <= c) << std::endl;
  std::cout << (a > c) << std::endl;
  std::cout << (a >= c) << std::endl;
}

出力例

true
false
false
true
true

バージョン

言語

  • C++20

処理系

参照