std::chrono:: operator==,<=> (std::chrono::day)
From cppreference.net
C++
Date and time library
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
std::chrono::day
| Member functions | ||||
| Nonmember functions | ||||
|
operator==
operator<=>
|
||||
| Helper classes | ||||
|
(C++26)
|
|
Определено в заголовочном файле
<chrono>
|
||
|
constexpr
bool
operator
==
(
const
std::
chrono
::
day
&
x,
const std:: chrono :: day & y ) noexcept ; |
(1) | (начиная с C++20) |
|
constexpr
std::
strong_ordering
operator
<=>
(
const
std::
chrono
::
day
&
x,
const std:: chrono :: day & y ) noexcept ; |
(2) | (начиная с C++20) |
Сравните два std::chrono::day x и y .
Операторы
<
,
<=
,
>
,
>=
и
!=
синтезируются
соответственно
из
operator
<=>
и
operator
==
.
Возвращаемое значение
1)
unsigned
(
x
)
==
unsigned
(
y
)
2)
unsigned
(
x
)
<=>
unsigned
(
y
)
Пример
Запустить этот код
#include <chrono> #include <iostream> int main() { constexpr std::chrono::day x{13}, y{31}; static_assert(x != y); if constexpr (constexpr auto res = x <=> y; res < 0) std::cout << "x меньше y\n"; else if constexpr (res > 0) std::cout << "x больше y\n"; else std::cout << "x и y равны\n"; using namespace std::literals::chrono_literals; static_assert ( (6d < 9d) && (6d == 6d) && (6d <= 9d) && (9d > 6d) && (9d != 6d) && (9d >= 6d) ); }
Вывод:
x меньше y