- chrono[meta header]
- std::chrono[meta namespace]
- function[meta id-type]
- cpp20[meta cpp]
namespace std::chrono {
constexpr strong_ordering operator<=>(const year& x, const year& y) noexcept; // (1) C++20
}year同士の三方比較を行う。
- (1) :
static_cast<int>(x) <=> static_cast<int>(y);
投げない
- この演算子により、
operator<、operator<=、operator>、operator>=が使用可能になる
#include <cassert>
#include <chrono>
namespace chrono = std::chrono;
int main()
{
assert((chrono::year{2020} <=> chrono::year{2020}) == 0);
assert(chrono::year{2019} < chrono::year{2020});
assert(chrono::year{2019} <= chrono::year{2020});
assert(chrono::year{2020} > chrono::year{2019});
assert(chrono::year{2020} >= chrono::year{2019});
}- C++20
- Clang: 9.0 [mark noimpl]
- GCC: 9.2 [mark noimpl]
- Visual C++: 2019 Update 3 [mark noimpl]