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>
41struct common_type<time_point<Clock, Dur1>, time_point<Clock, Dur2>>
42: inner::__timepoint_common_type<common_type<Dur1, Dur2>, Clock> {};
44template <
typename Clock,
typename Dur>
45struct common_type<time_point<Clock, Dur>, time_point<Clock, Dur>> {
46 using type = time_point<Clock, Dur>;
49template <
typename Clock,
typename Dur>
50struct common_type<time_point<Clock, 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_) {}
191 NEFORCE_ALWAYS_INLINE time_point<Clock, microseconds> to_micro()
const {
192 return _NEFORCE time_cast<microseconds>(*
this);
194 NEFORCE_ALWAYS_INLINE time_point<Clock, milliseconds> to_milli()
const {
195 return _NEFORCE time_cast<milliseconds>(*
this);
197 NEFORCE_ALWAYS_INLINE time_point<Clock, seconds> to_sec()
const {
return _NEFORCE time_cast<seconds>(*
this); }
198 NEFORCE_ALWAYS_INLINE time_point<Clock, minutes> to_minu()
const {
return _NEFORCE time_cast<minutes>(*
this); }
199 NEFORCE_ALWAYS_INLINE time_point<Clock, hours> to_hour()
const {
return _NEFORCE time_cast<hours>(*
this); }
200 NEFORCE_ALWAYS_INLINE time_point<Clock, days> to_day()
const {
return _NEFORCE time_cast<days>(*
this); }
201 NEFORCE_ALWAYS_INLINE time_point<Clock, weeks> to_week()
const {
return _NEFORCE time_cast<weeks>(*
this); }
202 NEFORCE_ALWAYS_INLINE time_point<Clock, years> to_year()
const {
return _NEFORCE time_cast<years>(*
this); }
203 NEFORCE_ALWAYS_INLINE time_point<Clock, months> to_month()
const {
return _NEFORCE time_cast<months>(*
this); }
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>
241constexpr time_point<Clock, common_type_t<duration<Rep1, Period1>, Dur2>>
259template <
typename Clock,
typename Dur1,
typename Rep2,
typename Period2>
260constexpr time_point<Clock, common_type_t<Dur1, duration<Rep2, 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__
constexpr ToDur time_cast(const duration< Rep, Period > &value)
持续时间类型转换
constexpr bool is_duration_v
is_duration的便捷变量模板
bool operator!=(const function< Res(Args...)> &f, nullptr_t np) noexcept
不等于空指针比较
bool operator==(const function< Res(Args...)> &f, nullptr_t np) noexcept
等于空指针比较
constexpr auto operator-(const normal_iterator< LeftIter > &lhs, const normal_iterator< RightIter > &rhs) noexcept -> decltype(lhs.base() - rhs.base())
减法运算符
constexpr normal_iterator< Iterator > operator+(iter_difference_t< normal_iterator< Iterator > > n, const normal_iterator< Iterator > &iter) noexcept
加法运算符
typename common_type< Types... >::type common_type_t
common_type的便捷别名
constexpr duration()=default
默认构造函数
constexpr time_point(const time_point< clock_type, Dur2 > &value)
从其他时间点构造
constexpr time_point operator--(int)
后置自减运算符
constexpr time_point & operator++()
前置自增运算符
constexpr time_point & operator+=(const duration_type &dur)
加法赋值运算符
constexpr time_point(const duration_type &dur)
从持续时间构造
typename duration_type::rep rep
数值类型
static constexpr time_point min() noexcept
获取最小时间点
static constexpr time_point max() noexcept
获取最大时间点
constexpr time_point operator++(int)
后置自增运算符
constexpr duration_type since_epoch() const noexcept
获取自纪元以来的时间
typename duration_type::period period
时间单位比例
constexpr time_point & operator--()
前置自减运算符
constexpr time_point()
默认构造函数
constexpr time_point & operator-=(const duration_type &dur)
减法赋值运算符