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
処理系
- Clang:
- GCC: 10 ✅
- Visual C++: ??
参照
- P1614R2 The Mothership has Landed
- C++20での三方比較演算子の追加と、関連する演算子の自動導出