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

履歴 編集

function template
<chrono>

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

namespace std::chrono {
  template <class Clock, class Duration1,
    three_way_comparable_with<Duration1> Duration2>
  constexpr auto
    operator<=>(const time_point<Clock, Duration1>& lhs,
                const time_point<Clock, Duration2>& rhs); // (1) C++20
}

概要

三方比較を行う

戻り値

return lhs.time_since_epoch() <=> rhs.time_since_poch();

#include <cassert>
#include <chrono>

using namespace std::chrono;

int main()
{
  time_point<system_clock> tp1{ seconds{3} };
  time_point<system_clock> tp2{ seconds{3} };
  time_point<system_clock> tp3{ seconds{4} };

  assert((tp1 <=> tp2) == 0);
  assert((tp1 <=> tp3) != 0);
}

出力

バージョン

言語

  • C++20

処理系

参照