- chrono[meta header]
- std::chrono[meta namespace]
- function template[meta id-type]
- cpp20[meta cpp]
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
}- time_point[link /reference/chrono/time_point.md]
三方比較を行う
return lhs.time_since_epoch() <=> rhs.time_since_poch();- time_since_epoch[link /reference/chrono/time_point/time_since_epoch.md]
#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);
}- system_clock[link /reference/chrono/system_clock.md]
- C++20
- Clang:
- GCC: 10
- Visual C++: ??
- P1614R2 The Mothership has Landed
- C++20での三方比較演算子の追加と、関連する演算子の自動導出