Namensräume
Varianten
Aktionen

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

Von cppreference.com
< cpp‎ | chrono‎ | time point
 
 
 
std::chrono::time_point
Memberfunktionen
Nicht-Member-Funktionen
operator==operator!=operator<operator<=operator>operator>=operator<=>
(bis C++20)(C++20)
(C++17)
(C++17)
(C++17)
Hilfsklassen
 
Definiert in Header <chrono>
(1)
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 );
(seit C++11)
(bis 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 );
(seit C++14)
(2)
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 );
(seit C++11)
(bis 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 );
(seit C++14)
(bis C++20)
(3)
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 );
(seit C++11)
(bis 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 );
(seit C++14)
(4)
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 );
(seit C++11)
(bis 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 );
(seit C++14)
(5)
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 );
(seit C++11)
(bis 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 );
(seit C++14)
(6)
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 );
(seit C++11)
(bis 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 );
(seit 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) (seit C++20)

Vergleicht zwei Zeitpunkte. Der Vergleich erfolgt durch den Vergleich der Ergebnisse von time_since_epoch() für die Zeitpunkte.

1,2) Prüft, ob die Zeitpunkte lhs und rhs für die gegebene Uhr dieselbe Zeit repräsentieren.
3-6) Vergleicht die Zeitpunkte lhs und rhs.
7) Vergleicht die Zeitpunkte lhs und rhs. Der Rückgabetyp wird aus lhs.time_since_epoch() <=> rhs.time_since_epoch() abgeleitet, und somit aus dem Typ des Drei-Wege-Vergleichsergebnisses von Dur1 und Dur2.

Der Operator != wird aus operator== synthetisiert.

(seit C++20)

Inhalt

[bearbeiten] Parameter

lhs, rhs - zu vergleichende Zeitpunkte

[bearbeiten] Rückgabewert

1) true, wenn lhs und rhs denselben Zeitpunkt repräsentieren, sonst false.
2) true, wenn lhs und rhs unterschiedliche Zeitpunkte repräsentieren, sonst false.
3) true, wenn lhs zu einem Zeitpunkt *vor* rhs liegt, sonst false.
4) true, wenn lhs zu einem Zeitpunkt *vor* rhs liegt oder zum selben Zeitpunkt wie rhs, sonst false.
5) true, wenn lhs zu einem Zeitpunkt *nach* rhs liegt, sonst false.
6) true, wenn lhs zu einem Zeitpunkt *nach* rhs liegt oder zum selben Zeitpunkt wie rhs, sonst false.
7) lhs.time_since_epoch() <=> rhs.time_since_epoch().

[edit] Exceptions

Kann implementierungsdefinierte Ausnahmen auslösen.

[bearbeiten] Anmerkungen

Zwei-Wege-Vergleichsoperatoren von time_point waren in C++11 nicht constexpr. Dies wurde in C++14 korrigiert.