operator==,!=,<,<=,>,>=,<=>(std::chrono::time_point)
时间点 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
时长 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
时钟 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
当天时刻 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
日历 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
时区 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
chrono
I/O
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
(C++20)
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
C 风格日期和时间 |
成员函数 | ||||
(C++20)(C++20)
|
||||
非成员函数 | ||||
operator==operator!=operator<operator<=operator>operator>=operator<=>
(C++20
前)(C++20)
|
||||
(C++17)
|
||||
(C++17)
|
||||
(C++17)
|
||||
辅助类 | ||||
(C++26)
|
在标头
<chrono>
定义
|
||
(1) | ||
template<
class
Clock, class
Dur1, class
Dur2 >
bool
operator==(
const
std::chrono::time_point<Clock,Dur1>&
lhs, |
(C++11
起) (C++14 前) |
|
template<
class
Clock, class
Dur1, class
Dur2 >
constexpr
bool
operator==(
const
std::chrono::time_point<Clock,Dur1>&
lhs, |
(C++14 起) | |
(2) | ||
template<
class
Clock, class
Dur1, class
Dur2 >
bool
operator!=(
const
std::chrono::time_point<Clock,Dur1>&
lhs, |
(C++11
起) (C++14 前) |
|
template<
class
Clock, class
Dur1, class
Dur2 >
constexpr
bool
operator!=(
const
std::chrono::time_point<Clock,Dur1>&
lhs, |
(C++14
起) (C++20 前) |
|
(3) | ||
template<
class
Clock, class
Dur1, class
Dur2 >
bool
operator<(
const
std::chrono::time_point<Clock,Dur1>&
lhs, |
(C++11
起) (C++14 前) |
|
template<
class
Clock, class
Dur1, class
Dur2 >
constexpr
bool
operator<(
const
std::chrono::time_point<Clock,Dur1>&
lhs, |
(C++14 起) | |
(4) | ||
template<
class
Clock, class
Dur1, class
Dur2 >
bool
operator<=(
const
std::chrono::time_point<Clock,Dur1>&
lhs, |
(C++11
起) (C++14 前) |
|
template<
class
Clock, class
Dur1, class
Dur2 >
constexpr
bool
operator<=(
const
std::chrono::time_point<Clock,Dur1>&
lhs, |
(C++14 起) | |
(5) | ||
template<
class
Clock, class
Dur1, class
Dur2 >
bool
operator>(
const
std::chrono::time_point<Clock,Dur1>&
lhs, |
(C++11
起) (C++14 前) |
|
template<
class
Clock, class
Dur1, class
Dur2 >
constexpr
bool
operator>(
const
std::chrono::time_point<Clock,Dur1>&
lhs, |
(C++14 起) | |
(6) | ||
template<
class
Clock, class
Dur1, class
Dur2 >
bool
operator>=(
const
std::chrono::time_point<Clock,Dur1>&
lhs, |
(C++11
起) (C++14 前) |
|
template<
class
Clock, class
Dur1, class
Dur2 >
constexpr
bool
operator>=(
const
std::chrono::time_point<Clock,Dur1>&
lhs, |
(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, |
(7) | (C++20 起) |
比较二个时间点。以比较 time_since_epoch() 对这些时间点的结果进行比较。
lhs
与 rhs
是否给定时钟的同一时间点。lhs
与 rhs
。lhs
与
rhs
。返回类型从 lhs.time_since_epoch()
<=> rhs.time_since_epoch() 推导,从而为
Dur1
与 Dur2
的三路比较结果类型。
|
(C++20 起) |
参数
lhs, rhs | - | 要比较的 time_point |
返回值
lhs
与
rhs
指代同一时间点则为 true ,否则为 false 。lhs
与
rhs
指代不同时间点则为 true ,否则为 false 。lhs
指代的时间点先于 rhs
则为 true ,否则为 false 。lhs
指代的时间点先于 rhs
,或指代的时间点与 rhs
相同则为 true ,否则为 false 。lhs
指代的时间点后于 rhs
则为 ,否则为 false 。lhs
指代的时间点后于 rhs
,或指代的时间点与 rhs
相同则为 true ,否则为 false 。异常
可能会抛出由实现定义的异常。
注解
time_point
的双路比较运算符曾在 C++11 中不是 constexpr
,这在 C++14
中更正。