1#ifndef NEFORCE_CORE_TIME_TIME_POINT_HPP__
2#define NEFORCE_CORE_TIME_TIME_POINT_HPP__
12NEFORCE_BEGIN_NAMESPACE__
14template <
typename Clock,
typename Dur =
typename Clock::duration>
29template <
typename CommonT,
typename Clock,
typename Dummy =
void>
30struct __timepoint_common_type {};
32template <
typename CommonT,
typename Clock>
33struct __timepoint_common_type<CommonT, Clock,
void_t<typename CommonT::type>> {
34 using type = time_point<Clock, typename CommonT::type>;
40template <
typename Clock,
typename Dur1,
typename Dur2>
42: inner::__timepoint_common_type<common_type<Dur1, Dur2>, Clock> {};
44template <
typename Clock,
typename Dur>
46 using type = time_point<Clock, Dur>;
49template <
typename Clock,
typename Dur>
51 using type = time_point<Clock, Dur>;
70template <
typename ToDur,
typename Clock,
typename Dur, enable_if_t<is_duration_v<ToDur>,
int> = 0>
83template <
typename Clock,
typename Dur>
89 using rep =
typename duration_type::rep;
90 using period =
typename duration_type::period;
114 template <
typename Dur2,
typename = enable_if_t<is_convertible_v<Dur2, duration_type>>>
116 value_(value.value_) {}
206template <
typename Rep,
typename Period>
207template <
typename Clock,
typename Dur,
typename Dummy>
221template <
typename Clock,
typename Dur1,
typename Rep2,
typename Period2>
240template <
typename Rep1,
typename Period1,
typename Clock,
typename Dur2>
259template <
typename Clock,
typename Dur1,
typename Rep2,
typename Period2>
277template <
typename Clock,
typename Dur1,
typename Dur2>
291template <
typename Clock,
typename Dur1,
typename Dur2>
305template <
typename Clock,
typename Dur1,
typename Dur2>
307 return !(lhs == rhs);
319template <
typename Clock,
typename Dur1,
typename Dur2>
333template <
typename Clock,
typename Dur1,
typename Dur2>
347template <
typename Clock,
typename Dur1,
typename Dur2>
361template <
typename Clock,
typename Dur1,
typename Dur2>
368NEFORCE_END_NAMESPACE__
NEFORCE_INLINE17 constexpr bool is_duration_v
is_duration的便捷变量模板
constexpr ToDur time_cast(const duration< Rep, Period > &value)
持续时间类型转换
constexpr bool operator>=(const time_point< Clock, Dur1 > &lhs, const time_point< Clock, Dur2 > &rhs)
大于等于比较运算符
constexpr bool operator!=(const time_point< Clock, Dur1 > &lhs, const time_point< Clock, Dur2 > &rhs)
不等于比较运算符
constexpr time_point< Clock, common_type_t< Dur1, duration< Rep2, Period2 > > > operator-(const time_point< Clock, Dur1 > &lhs, const duration< Rep2, Period2 > &rhs)
减法运算符(时间点 - 持续时间)
constexpr time_point< Clock, ToDur > time_cast(const time_point< Clock, Dur > &time_point_value)
时间点类型转换
constexpr bool operator>(const time_point< Clock, Dur1 > &lhs, const time_point< Clock, Dur2 > &rhs)
大于比较运算符
constexpr time_point< Clock, common_type_t< Dur1, duration< Rep2, Period2 > > > operator+(const time_point< Clock, Dur1 > &lhs, const duration< Rep2, Period2 > &rhs)
加法运算符(时间点 + 持续时间)
constexpr bool operator<=(const time_point< Clock, Dur1 > &lhs, const time_point< Clock, Dur2 > &rhs)
小于等于比较运算符
constexpr bool operator<(const time_point< Clock, Dur1 > &lhs, const time_point< Clock, Dur2 > &rhs)
小于比较运算符
constexpr bool operator==(const time_point< Clock, Dur1 > &lhs, const time_point< Clock, Dur2 > &rhs)
等于比较运算符
typename common_type< Types... >::type common_type_t
common_type的便捷别名
constexpr duration()=default
默认构造函数
typename duration_type::period period
时间单位比例
constexpr time_point()
默认构造函数
constexpr time_point & operator++()
前置自增运算符
constexpr time_point(const duration_type &dur)
从持续时间构造
constexpr time_point & operator+=(const duration_type &dur)
加法赋值运算符
constexpr time_point operator++(int)
后置自增运算符
constexpr time_point(const time_point< clock_type, Dur2 > &value)
从其他时间点构造
static constexpr time_point max() noexcept
获取最大时间点
constexpr duration_type since_epoch() const noexcept
获取自纪元以来的时间
constexpr time_point & operator-=(const duration_type &dur)
减法赋值运算符
typename duration_type::rep rep
数值类型
constexpr time_point operator--(int)
后置自减运算符
static constexpr time_point min() noexcept
获取最小时间点
constexpr time_point & operator--()
前置自减运算符