名前空間
変種
操作

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

From cppreference.com
< cpp‎ | chrono‎ | time point
 
 
 
std::chrono::time_point
メンバ関数
非メンバ関数
operator==operator!=operator<operator<=operator>operator>=operator<=>
(C++20まで)(C++20以降)
(C++17)
(C++17)
(C++17)
ヘルパークラス
 
ヘッダー <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 );
(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以降)
(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 );
(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まで)
(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 );
(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以降)
(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 );
(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以降)
(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 );
(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以降)
(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 );
(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 pointの`time_since_epoch()`の結果を比較します。

1,2) 与えられたクロックで、time point `lhs` と `rhs` が同じ時刻を参照しているかどうかをチェックします。
3-6) time point `lhs` と `rhs` を比較します。
7) time point `lhs` と `rhs` を比較します。返り値の型は `lhs.time_since_epoch() <=> rhs.time_since_epoch()` から推論され、したがって `Dur1` と `Dur2` の三項比較結果の型となります。

!= 演算子は operator== から合成される。

(C++20以降)

目次

[edit] パラメータ

lhs, rhs - 比較する time points

[edit] 返り値

1) `lhs` と `rhs` が同じ time point を参照している場合は `true`、そうでなければ `false`。
2) `lhs` と `rhs` が異なる time point を参照している場合は `true`、そうでなければ `false`。
3) `lhs` が `rhs` より前の time point を参照している場合は `true`、そうでなければ `false`。
4) `lhs` が `rhs` より前の time point を参照しているか、または `rhs` と同じ time point を参照している場合は `true`、そうでなければ `false`。
5) `lhs` が `rhs` より後の time point を参照している場合は `true`、そうでなければ `false`。
6) `lhs` が `rhs` より後の time point を参照しているか、または `rhs` と同じ time point を参照している場合は `true`、そうでなければ `false`。
7) `lhs.time_since_epoch() <=> rhs.time_since_epoch()`。

[編集] 例外

実装定義の例外をスローする場合があります。

[edit] 注記

C++11 では `time_point` の双方向比較演算子は `constexpr` ではありませんでしたが、C++14 で修正されました。

English 日本語 中文(简体) 中文(繁體)