Spec-Zone.ru › C++

operator==,!=,<,<=,>,>=,<=>(std::chrono::time_point)

Определён в заголовочном файле <chrono>
template< class Clock, class Dur1, class Dur2 >
bool operator==( const std::chrono::time_point<Clock,Dur1>& lhs,
                 const std::chrono::time_point<Clock,Dur2>& rhs );
(1) (начиная с C++11)
(до C++14)
template< class Clock, class Dur1, class Dur2 >
constexpr bool operator==( const std::chrono::time_point<Clock,Dur1>& lhs,
                           const std::chrono::time_point<Clock,Dur2>& rhs );
(начиная с C++14)
template< class Clock, class Dur1, class Dur2 >
bool operator!=( const std::chrono::time_point<Clock,Dur1>& lhs,
                 const std::chrono::time_point<Clock,Dur2>& rhs );
(2) (начиная с C++11)
(до C++14)
template< class Clock, class Dur1, class Dur2 >
constexpr bool operator!=( const std::chrono::time_point<Clock,Dur1>& lhs,
                           const std::chrono::time_point<Clock,Dur2>& rhs );
(начиная с C++14)
(до C++20)
template< class Clock, class Dur1, class Dur2 >
bool operator<( const std::chrono::time_point<Clock,Dur1>& lhs,
                const std::chrono::time_point<Clock,Dur2>& rhs );
(3) (начиная с C++11)
(до C++14)
template< class Clock, class Dur1, class Dur2 >
constexpr bool operator<( const std::chrono::time_point<Clock,Dur1>& lhs,
                          const std::chrono::time_point<Clock,Dur2>& rhs );
(начиная с C++14)
template< class Clock, class Dur1, class Dur2 >
bool operator<=( const std::chrono::time_point<Clock,Dur1>& lhs,
                 const std::chrono::time_point<Clock,Dur2>& rhs );
(4) (начиная с C++11)
(до C++14)
template< class Clock, class Dur1, class Dur2 >
constexpr bool operator<=( const std::chrono::time_point<Clock,Dur1>& lhs,
                           const std::chrono::time_point<Clock,Dur2>& rhs );
(начиная с C++14)
template< class Clock, class Dur1, class Dur2 >
bool operator>( const std::chrono::time_point<Clock,Dur1>& lhs,
                const std::chrono::time_point<Clock,Dur2>& rhs );
(5) (начиная с C++11)
(до C++14)
template< class Clock, class Dur1, class Dur2 >
constexpr bool operator>( const std::chrono::time_point<Clock,Dur1>& lhs,
                          const std::chrono::time_point<Clock,Dur2>& rhs );
(начиная с C++14)
template< class Clock, class Dur1, class Dur2 >
bool operator>=( const std::chrono::time_point<Clock,Dur1>& lhs,
                 const std::chrono::time_point<Clock,Dur2>& rhs );
(6) (начиная с C++11)
(до C++14)
template< class Clock, class Dur1, class Dur2 >
constexpr bool operator>=( const std::chrono::time_point<Clock,Dur1>& lhs,
                           const std::chrono::time_point<Clock,Dur2>& rhs );
(начиная с C++14)
template< class Clock, class Dur1, std::three_way_comparable_with<Dur1> Dur2 >
constexpr auto operator<=>( const std::chrono::time_point<Clock,Dur1>& lhs,
                            const std::chrono::time_point<Clock,Dur2>& rhs );
(7) (начиная с C++20)

Сравнивает две временные точки. Сравнение выполняется путём сравнения результатов time_since_epoch() для временных точек.

1,2) Проверяет, указывают ли временные точки lhs и rhs на одну и ту же временную точку для заданных часов.
3-6) Сравнивает временные точки lhs и rhs.
7) Сравнивает временные точки lhs и rhs. Тип возвращаемого значения выводится из lhs.time_since_epoch() <=> rhs.time_since_epoch(), а значит, является типом результата трёхстороннего сравнения Dur1 и Dur2.

Оператор != синтезируется из operator==.

(начиная с C++20)

Параметры

lhs, rhs - временные точки для сравнения

Возвращаемое значение

1) true, если lhs и rhs указывают на одну и ту же временную точку, и false в противном случае.
2) true, если lhs и rhs указывают на разные временные точки, и false в противном случае.
3) true, если lhs указывает на временную точку, расположенную до rhs, и false в противном случае.
4) true, если lhs указывает на временную точку, расположенную до rhs, или на ту же временную точку, что и rhs, и false в противном случае.
5) true, если lhs указывает на временную точку, расположенную после rhs, и false в противном случае.
6) true, если lhs указывает на временную точку, расположенную после rhs, или на ту же временную точку, что и rhs, и false в противном случае.
7) lhs.time_since_epoch() <=> rhs.time_since_epoch().

Исключения

Может выбрасывать исключения, определяемые реализацией.

Примечания

Операторы бинарного сравнения для time_point не были constexpr в C++11; это было исправлено в C++14.

© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
https://en.cppreference.com/cpp/chrono/time_point/operator_cmp

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API