30 #ifndef _GLIBCXX_CHRONO
31 #define _GLIBCXX_CHRONO 1
33 #pragma GCC system_header
35 #if __cplusplus < 201103L
44 #if __cplusplus > 201703L
49 namespace std _GLIBCXX_VISIBILITY(default)
51 _GLIBCXX_BEGIN_NAMESPACE_VERSION
53 #if __cplusplus >= 201703L
54 namespace filesystem {
struct __file_clock; };
70 template<
typename _Rep,
typename _Period = ratio<1>>
73 template<
typename _Clock,
typename _Dur =
typename _Clock::duration>
81 template<
typename _CT,
typename _Period1,
typename _Period2,
typename =
void>
82 struct __duration_common_type
85 template<
typename _CT,
typename _Period1,
typename _Period2>
86 struct __duration_common_type<_CT, _Period1, _Period2,
87 __void_t<typename _CT::type>>
90 using __gcd_num = __static_gcd<_Period1::num, _Period2::num>;
91 using __gcd_den = __static_gcd<_Period1::den, _Period2::den>;
92 using __cr =
typename _CT::type;
93 using __r =
ratio<__gcd_num::value,
94 (_Period1::den / __gcd_den::value) * _Period2::den>;
104 template<
typename _Rep1,
typename _Period1,
typename _Rep2,
typename _Period2>
107 : __duration_common_type<common_type<_Rep1, _Rep2>,
108 typename _Period1::type,
109 typename _Period2::type>
114 template<
typename _Rep,
typename _Period>
119 typename _Period::type>;
124 template<
typename _Rep,
typename _Period>
128 typename _Period::type>;
135 template<
typename _CT,
typename _Clock,
typename =
void>
136 struct __timepoint_common_type
139 template<
typename _CT,
typename _Clock>
140 struct __timepoint_common_type<_CT, _Clock, __void_t<typename _CT::type>>
142 using type = chrono::time_point<_Clock, typename _CT::type>;
149 template<
typename _Clock,
typename _Duration1,
typename _Duration2>
152 : __timepoint_common_type<common_type<_Duration1, _Duration2>, _Clock>
157 template<
typename _Clock,
typename _Duration>
164 template<
typename _Clock,
typename _Duration>
178 template<
typename _ToDur,
typename _CF,
typename _CR,
179 bool _NumIsOne =
false,
bool _DenIsOne =
false>
180 struct __duration_cast_impl
182 template<
typename _Rep,
typename _Period>
183 static constexpr _ToDur
184 __cast(
const duration<_Rep, _Period>& __d)
186 typedef typename _ToDur::rep __to_rep;
187 return _ToDur(static_cast<__to_rep>(static_cast<_CR>(__d.count())
188 * static_cast<_CR>(_CF::num)
189 /
static_cast<_CR
>(_CF::den)));
193 template<
typename _ToDur,
typename _CF,
typename _CR>
194 struct __duration_cast_impl<_ToDur, _CF, _CR, true, true>
196 template<
typename _Rep,
typename _Period>
197 static constexpr _ToDur
198 __cast(
const duration<_Rep, _Period>& __d)
200 typedef typename _ToDur::rep __to_rep;
201 return _ToDur(static_cast<__to_rep>(__d.count()));
205 template<
typename _ToDur,
typename _CF,
typename _CR>
206 struct __duration_cast_impl<_ToDur, _CF, _CR, true, false>
208 template<
typename _Rep,
typename _Period>
209 static constexpr _ToDur
210 __cast(
const duration<_Rep, _Period>& __d)
212 typedef typename _ToDur::rep __to_rep;
213 return _ToDur(static_cast<__to_rep>(
214 static_cast<_CR>(__d.count()) / static_cast<_CR>(_CF::den)));
218 template<
typename _ToDur,
typename _CF,
typename _CR>
219 struct __duration_cast_impl<_ToDur, _CF, _CR, false, true>
221 template<
typename _Rep,
typename _Period>
222 static constexpr _ToDur
223 __cast(
const duration<_Rep, _Period>& __d)
225 typedef typename _ToDur::rep __to_rep;
226 return _ToDur(static_cast<__to_rep>(
227 static_cast<_CR>(__d.count()) * static_cast<_CR>(_CF::num)));
231 template<
typename _Tp>
236 template<
typename _Rep,
typename _Period>
237 struct __is_duration<duration<_Rep, _Period>>
241 template<
typename _Tp>
242 using __enable_if_is_duration
243 =
typename enable_if<__is_duration<_Tp>::value, _Tp>::type;
245 template<
typename _Tp>
246 using __disable_if_is_duration
247 =
typename enable_if<!__is_duration<_Tp>::value, _Tp>::type;
252 template<
typename _ToDur,
typename _Rep,
typename _Period>
253 constexpr __enable_if_is_duration<_ToDur>
256 typedef typename _ToDur::period __to_period;
257 typedef typename _ToDur::rep __to_rep;
261 typedef __duration_cast_impl<_ToDur, __cf, __cr,
262 __cf::num == 1, __cf::den == 1> __dc;
263 return __dc::__cast(__d);
267 template<
typename _Rep>
272 #if __cplusplus > 201402L
273 template <
typename _Rep>
274 inline constexpr
bool treat_as_floating_point_v =
278 #if __cplusplus > 201703L
279 template<
typename _Tp>
282 template<
typename _Tp>
283 inline constexpr
bool is_clock_v = is_clock<_Tp>::value;
285 #if __cpp_lib_concepts
286 template<
typename _Tp>
290 template<
typename _Tp>
293 typename _Tp::period;
294 typename _Tp::duration;
295 typename _Tp::time_point::clock;
296 typename _Tp::time_point::duration;
297 { &_Tp::is_steady } -> same_as<const bool*>;
298 { _Tp::now() } -> same_as<typename _Tp::time_point>;
299 requires same_as<
typename _Tp::duration,
300 duration<typename _Tp::rep, typename _Tp::period>>;
301 requires same_as<
typename _Tp::time_point::duration,
302 typename _Tp::duration>;
307 template<
typename _Tp,
typename =
void>
311 template<
typename _Tp>
312 struct __is_clock_impl<_Tp,
313 void_t<typename _Tp::rep, typename _Tp::period,
314 typename _Tp::duration,
315 typename _Tp::time_point::duration,
316 decltype(_Tp::is_steady),
317 decltype(_Tp::now())>>
318 : __and_<is_same<typename _Tp::duration,
319 duration<typename _Tp::rep, typename _Tp::period>>,
320 is_same<typename _Tp::time_point::duration,
321 typename _Tp::duration>,
322 is_same<decltype(&_Tp::is_steady), const bool*>,
323 is_same<decltype(_Tp::now()), typename _Tp::time_point>>::type
326 template<
typename _Tp>
327 struct is_clock : __is_clock_impl<_Tp>::type
332 #if __cplusplus >= 201703L
333 # define __cpp_lib_chrono 201611
335 template<
typename _ToDur,
typename _Rep,
typename _Period>
336 constexpr __enable_if_is_duration<_ToDur>
337 floor(
const duration<_Rep, _Period>& __d)
341 return __to - _ToDur{1};
345 template<
typename _ToDur,
typename _Rep,
typename _Period>
346 constexpr __enable_if_is_duration<_ToDur>
347 ceil(
const duration<_Rep, _Period>& __d)
351 return __to + _ToDur{1};
355 template <
typename _ToDur,
typename _Rep,
typename _Period>
357 __and_<__is_duration<_ToDur>,
358 __not_<treat_as_floating_point<typename _ToDur::rep>>>::value,
360 round(
const duration<_Rep, _Period>& __d)
362 _ToDur __t0 = chrono::floor<_ToDur>(__d);
363 _ToDur __t1 = __t0 + _ToDur{1};
364 auto __diff0 = __d - __t0;
365 auto __diff1 = __t1 - __d;
366 if (__diff0 == __diff1)
368 if (__t0.count() & 1)
372 else if (__diff0 < __diff1)
377 template<
typename _Rep,
typename _Period>
379 enable_if_t<numeric_limits<_Rep>::is_signed, duration<_Rep, _Period>>
380 abs(duration<_Rep, _Period> __d)
382 if (__d >= __d.zero())
388 namespace __detail {
using chrono::ceil; }
397 template<
typename _Tp,
typename _Up>
399 __ceil_impl(
const _Tp& __t,
const _Up& __u)
401 return (__t < __u) ? (__t + _Tp{1}) : __t;
405 template<
typename _ToDur,
typename _Rep,
typename _Period>
407 ceil(
const duration<_Rep, _Period>& __d)
409 return __detail::__ceil_impl(chrono::duration_cast<_ToDur>(__d), __d);
415 template<
typename _Rep>
418 static constexpr _Rep
422 static constexpr _Rep
426 static constexpr _Rep
433 template<
typename _Tp>
438 template<
intmax_t _Num,
intmax_t _Den>
439 struct __is_ratio<
ratio<_Num, _Den>>
446 template<
typename _Rep,
typename _Period>
450 template<
typename _Rep2>
451 using __is_float = treat_as_floating_point<_Rep2>;
453 static constexpr intmax_t
454 _S_gcd(intmax_t __m, intmax_t __n) noexcept
458 #if __cplusplus >= 201402L
461 intmax_t __rem = __m % __n;
470 return (__n == 0) ? __m : _S_gcd(__n, __m % __n);
478 template<
typename _R1,
typename _R2,
479 intmax_t __gcd1 = _S_gcd(_R1::num, _R2::num),
480 intmax_t __gcd2 = _S_gcd(_R1::den, _R2::den)>
481 using __divide = ratio<(_R1::num / __gcd1) * (_R2::den / __gcd2),
482 (_R1::den / __gcd2) * (_R2::num / __gcd1)>;
485 template<
typename _Period2>
487 = __bool_constant<__divide<_Period2, _Period>::den == 1>;
492 using period =
typename _Period::type;
494 static_assert(!__is_duration<_Rep>::value,
"rep cannot be a duration");
495 static_assert(__is_ratio<_Period>::value,
496 "period must be a specialization of ratio");
497 static_assert(_Period::num > 0,
"period must be positive");
500 constexpr duration() =
default;
502 duration(
const duration&) =
default;
506 template<
typename _Rep2,
typename = _Require<
507 is_convertible<const _Rep2&, rep>,
508 __or_<__is_float<rep>, __not_<__is_float<_Rep2>>>>>
509 constexpr
explicit duration(
const _Rep2& __rep)
510 : __r(static_cast<rep>(__rep)) { }
512 template<
typename _Rep2,
typename _Period2,
typename = _Require<
513 is_convertible<const _Rep2&, rep>,
514 __or_<__is_float<rep>,
515 __and_<__is_harmonic<_Period2>,
516 __not_<__is_float<_Rep2>>>>>>
517 constexpr duration(
const duration<_Rep2, _Period2>& __d)
520 ~duration() =
default;
521 duration& operator=(
const duration&) =
default;
530 constexpr duration<typename common_type<rep>::type, period>
532 {
return duration<typename common_type<rep>::type, period>(__r); }
534 constexpr duration<typename common_type<rep>::type, period>
536 {
return duration<typename common_type<rep>::type, period>(-__r); }
538 _GLIBCXX17_CONSTEXPR duration&
545 _GLIBCXX17_CONSTEXPR duration
547 {
return duration(__r++); }
549 _GLIBCXX17_CONSTEXPR duration&
556 _GLIBCXX17_CONSTEXPR duration
558 {
return duration(__r--); }
560 _GLIBCXX17_CONSTEXPR duration&
561 operator+=(
const duration& __d)
567 _GLIBCXX17_CONSTEXPR duration&
568 operator-=(
const duration& __d)
574 _GLIBCXX17_CONSTEXPR duration&
575 operator*=(
const rep& __rhs)
581 _GLIBCXX17_CONSTEXPR duration&
582 operator/=(
const rep& __rhs)
589 template<
typename _Rep2 = rep>
591 typename enable_if<!treat_as_floating_point<_Rep2>::value,
593 operator%=(
const rep& __rhs)
599 template<
typename _Rep2 = rep>
601 typename enable_if<!treat_as_floating_point<_Rep2>::value,
603 operator%=(
const duration& __d)
610 static constexpr duration
612 {
return duration(duration_values<rep>::zero()); }
614 static constexpr duration
618 static constexpr duration
629 template<
typename _Rep1,
typename _Period1,
630 typename _Rep2,
typename _Period2>
631 constexpr
typename common_type<duration<_Rep1, _Period1>,
632 duration<_Rep2, _Period2>>::type
639 return __cd(__cd(__lhs).count() + __cd(__rhs).count());
643 template<
typename _Rep1,
typename _Period1,
644 typename _Rep2,
typename _Period2>
653 return __cd(__cd(__lhs).count() - __cd(__rhs).count());
664 template<
typename _Rep1,
typename _Rep2,
666 using __common_rep_t =
typename
674 template<
typename _Rep1,
typename _Period,
typename _Rep2>
680 return __cd(__cd(__d).count() * __s);
684 template<
typename _Rep1,
typename _Rep2,
typename _Period>
687 {
return __d * __s; }
689 template<
typename _Rep1,
typename _Period,
typename _Rep2>
696 return __cd(__cd(__d).count() / __s);
699 template<
typename _Rep1,
typename _Period1,
700 typename _Rep2,
typename _Period2>
702 operator/(
const duration<_Rep1, _Period1>& __lhs,
703 const duration<_Rep2, _Period2>& __rhs)
705 typedef duration<_Rep1, _Period1> __dur1;
706 typedef duration<_Rep2, _Period2> __dur2;
708 return __cd(__lhs).count() / __cd(__rhs).count();
712 template<
typename _Rep1,
typename _Period,
typename _Rep2>
714 duration<__common_rep_t<_Rep1, __disable_if_is_duration<_Rep2>>, _Period>
715 operator%(
const duration<_Rep1, _Period>& __d,
const _Rep2& __s)
717 typedef duration<typename common_type<_Rep1, _Rep2>::type, _Period>
719 return __cd(__cd(__d).count() % __s);
722 template<
typename _Rep1,
typename _Period1,
723 typename _Rep2,
typename _Period2>
724 constexpr
typename common_type<duration<_Rep1, _Period1>,
725 duration<_Rep2, _Period2>>::type
726 operator%(
const duration<_Rep1, _Period1>& __lhs,
727 const duration<_Rep2, _Period2>& __rhs)
729 typedef duration<_Rep1, _Period1> __dur1;
730 typedef duration<_Rep2, _Period2> __dur2;
731 typedef typename common_type<__dur1,__dur2>::type __cd;
732 return __cd(__cd(__lhs).count() % __cd(__rhs).count());
737 template<
typename _Rep1,
typename _Period1,
738 typename _Rep2,
typename _Period2>
740 operator==(
const duration<_Rep1, _Period1>& __lhs,
741 const duration<_Rep2, _Period2>& __rhs)
743 typedef duration<_Rep1, _Period1> __dur1;
744 typedef duration<_Rep2, _Period2> __dur2;
745 typedef typename common_type<__dur1,__dur2>::type __ct;
746 return __ct(__lhs).count() == __ct(__rhs).count();
749 template<
typename _Rep1,
typename _Period1,
750 typename _Rep2,
typename _Period2>
752 operator<(const duration<_Rep1, _Period1>& __lhs,
753 const duration<_Rep2, _Period2>& __rhs)
755 typedef duration<_Rep1, _Period1> __dur1;
756 typedef duration<_Rep2, _Period2> __dur2;
757 typedef typename common_type<__dur1,__dur2>::type __ct;
758 return __ct(__lhs).count() < __ct(__rhs).count();
761 #if __cpp_lib_three_way_comparison
762 template<
typename _Rep1,
typename _Period1,
763 typename _Rep2,
typename _Period2>
764 requires three_way_comparable<common_type_t<_Rep1, _Rep2>>
766 operator<=>(
const duration<_Rep1, _Period1>& __lhs,
767 const duration<_Rep2, _Period2>& __rhs)
769 using __ct = common_type_t<duration<_Rep1, _Period1>,
770 duration<_Rep2, _Period2>>;
771 return __ct(__lhs).count() <=> __ct(__rhs).count();
774 template<
typename _Rep1,
typename _Period1,
775 typename _Rep2,
typename _Period2>
777 operator!=(
const duration<_Rep1, _Period1>& __lhs,
778 const duration<_Rep2, _Period2>& __rhs)
779 {
return !(__lhs == __rhs); }
782 template<
typename _Rep1,
typename _Period1,
783 typename _Rep2,
typename _Period2>
785 operator<=(const duration<_Rep1, _Period1>& __lhs,
786 const duration<_Rep2, _Period2>& __rhs)
787 {
return !(__rhs < __lhs); }
789 template<
typename _Rep1,
typename _Period1,
790 typename _Rep2,
typename _Period2>
792 operator>(
const duration<_Rep1, _Period1>& __lhs,
793 const duration<_Rep2, _Period2>& __rhs)
794 {
return __rhs < __lhs; }
796 template<
typename _Rep1,
typename _Period1,
797 typename _Rep2,
typename _Period2>
799 operator>=(
const duration<_Rep1, _Period1>& __lhs,
800 const duration<_Rep2, _Period2>& __rhs)
801 {
return !(__lhs < __rhs); }
805 #ifdef _GLIBCXX_USE_C99_STDINT_TR1
806 # define _GLIBCXX_CHRONO_INT64_T int64_t
807 #elif defined __INT64_TYPE__
808 # define _GLIBCXX_CHRONO_INT64_T __INT64_TYPE__
811 "Representation type for nanoseconds must have at least 64 bits");
812 # define _GLIBCXX_CHRONO_INT64_T long long
833 #if __cplusplus > 201703L
847 #undef _GLIBCXX_CHRONO_INT64_T
850 template<
typename _Clock,
typename _Dur>
853 static_assert(__is_duration<_Dur>::value,
854 "duration must be a specialization of std::chrono::duration");
856 typedef _Clock clock;
858 typedef typename duration::rep rep;
859 typedef typename duration::period period;
861 constexpr
time_point() : __d(duration::zero())
864 constexpr
explicit time_point(
const duration& __dur)
869 template<
typename _Dur2,
870 typename = _Require<is_convertible<_Dur2, _Dur>>>
872 : __d(__t.time_since_epoch())
877 time_since_epoch()
const
880 #if __cplusplus > 201703L
881 constexpr time_point&
890 {
return time_point{__d++}; }
892 constexpr time_point&
901 {
return time_point{__d--}; }
905 _GLIBCXX17_CONSTEXPR time_point&
912 _GLIBCXX17_CONSTEXPR time_point&
920 static constexpr time_point
922 {
return time_point(duration::min()); }
924 static constexpr time_point
926 {
return time_point(duration::max()); }
933 template<
typename _ToDur,
typename _Clock,
typename _Dur>
935 time_point<_Clock, _ToDur>>::type
939 return __time_point(duration_cast<_ToDur>(__t.time_since_epoch()));
942 #if __cplusplus > 201402L
943 template<
typename _ToDur,
typename _Clock,
typename _Dur>
946 floor(
const time_point<_Clock, _Dur>& __tp)
948 return time_point<_Clock, _ToDur>{
949 chrono::floor<_ToDur>(__tp.time_since_epoch())};
952 template<
typename _ToDur,
typename _Clock,
typename _Dur>
954 enable_if_t<__is_duration<_ToDur>::value, time_point<_Clock, _ToDur>>
955 ceil(
const time_point<_Clock, _Dur>& __tp)
957 return time_point<_Clock, _ToDur>{
958 chrono::ceil<_ToDur>(__tp.time_since_epoch())};
961 template<
typename _ToDur,
typename _Clock,
typename _Dur>
963 __and_<__is_duration<_ToDur>,
964 __not_<treat_as_floating_point<typename _ToDur::rep>>>::value,
965 time_point<_Clock, _ToDur>>
966 round(
const time_point<_Clock, _Dur>& __tp)
968 return time_point<_Clock, _ToDur>{
969 chrono::round<_ToDur>(__tp.time_since_epoch())};
976 template<
typename _Clock,
typename _Dur1,
977 typename _Rep2,
typename _Period2>
978 constexpr time_point<_Clock,
979 typename common_type<_Dur1, duration<_Rep2, _Period2>>::type>
981 const duration<_Rep2, _Period2>& __rhs)
983 typedef duration<_Rep2, _Period2> __dur2;
986 return __time_point(__lhs.time_since_epoch() + __rhs);
990 template<
typename _Rep1,
typename _Period1,
991 typename _Clock,
typename _Dur2>
997 typedef duration<_Rep1, _Period1> __dur1;
1000 return __time_point(__rhs.time_since_epoch() + __lhs);
1004 template<
typename _Clock,
typename _Dur1,
1005 typename _Rep2,
typename _Period2>
1009 const duration<_Rep2, _Period2>& __rhs)
1011 typedef duration<_Rep2, _Period2> __dur2;
1014 return __time_point(__lhs.time_since_epoch() -__rhs);
1022 template<
typename _Clock,
typename _Dur1,
typename _Dur2>
1026 {
return __lhs.time_since_epoch() - __rhs.time_since_epoch(); }
1028 template<
typename _Clock,
typename _Dur1,
typename _Dur2>
1032 {
return __lhs.time_since_epoch() == __rhs.time_since_epoch(); }
1034 #if __cpp_lib_three_way_comparison
1035 template<
typename _Clock,
typename _Dur1,
1036 three_way_comparable_with<_Dur1> _Dur2>
1038 operator<=>(
const time_point<_Clock, _Dur1>& __lhs,
1039 const time_point<_Clock, _Dur2>& __rhs)
1040 {
return __lhs.time_since_epoch() <=> __rhs.time_since_epoch(); }
1042 template<
typename _Clock,
typename _Dur1,
typename _Dur2>
1044 operator!=(
const time_point<_Clock, _Dur1>& __lhs,
1045 const time_point<_Clock, _Dur2>& __rhs)
1046 {
return !(__lhs == __rhs); }
1049 template<
typename _Clock,
typename _Dur1,
typename _Dur2>
1051 operator<(const time_point<_Clock, _Dur1>& __lhs,
1052 const time_point<_Clock, _Dur2>& __rhs)
1053 {
return __lhs.time_since_epoch() < __rhs.time_since_epoch(); }
1055 template<
typename _Clock,
typename _Dur1,
typename _Dur2>
1057 operator<=(const time_point<_Clock, _Dur1>& __lhs,
1058 const time_point<_Clock, _Dur2>& __rhs)
1059 {
return !(__rhs < __lhs); }
1061 template<
typename _Clock,
typename _Dur1,
typename _Dur2>
1063 operator>(
const time_point<_Clock, _Dur1>& __lhs,
1064 const time_point<_Clock, _Dur2>& __rhs)
1065 {
return __rhs < __lhs; }
1067 template<
typename _Clock,
typename _Dur1,
typename _Dur2>
1069 operator>=(
const time_point<_Clock, _Dur1>& __lhs,
1070 const time_point<_Clock, _Dur2>& __rhs)
1071 {
return !(__lhs < __rhs); }
1093 inline namespace _V2 {
1104 typedef duration::rep rep;
1105 typedef duration::period period;
1108 static_assert(system_clock::duration::min()
1109 < system_clock::duration::zero(),
1110 "a clock's minimum duration cannot be less than its epoch");
1112 static constexpr
bool is_steady =
false;
1121 return std::time_t(duration_cast<chrono::seconds>
1122 (__t.time_since_epoch()).count());
1126 from_time_t(std::time_t __t) noexcept
1144 typedef duration::rep rep;
1145 typedef duration::period period;
1148 static constexpr
bool is_steady =
true;
1167 #if __cplusplus > 201703L
1168 template<
typename _Duration>
1170 using sys_seconds = sys_time<seconds>;
1171 using sys_days = sys_time<days>;
1173 using file_clock = ::std::filesystem::__file_clock;
1175 template<
typename _Duration>
1178 template<>
struct is_clock<system_clock> :
true_type { };
1179 template<>
struct is_clock<steady_clock> :
true_type { };
1180 template<>
struct is_clock<file_clock> :
true_type { };
1182 template<>
inline constexpr
bool is_clock_v<system_clock> =
true;
1183 template<>
inline constexpr
bool is_clock_v<steady_clock> =
true;
1184 template<>
inline constexpr
bool is_clock_v<file_clock> =
true;
1187 template<
typename _Duration>
1188 using local_time = time_point<local_t, _Duration>;
1189 using local_seconds = local_time<seconds>;
1190 using local_days = local_time<days>;
1196 template<
typename _Duration>
1197 using utc_time = time_point<utc_clock, _Duration>;
1198 using utc_seconds = utc_time<seconds>;
1200 template<
typename _Duration>
1201 using tai_time = time_point<tai_clock, _Duration>;
1202 using tai_seconds = tai_time<seconds>;
1204 template<
typename _Duration>
1205 using gps_time = time_point<gps_clock, _Duration>;
1206 using gps_seconds = gps_time<seconds>;
1208 template<>
struct is_clock<utc_clock> :
true_type { };
1209 template<>
struct is_clock<tai_clock> :
true_type { };
1210 template<>
struct is_clock<gps_clock> :
true_type { };
1212 template<>
inline constexpr
bool is_clock_v<utc_clock> =
true;
1213 template<>
inline constexpr
bool is_clock_v<tai_clock> =
true;
1214 template<>
inline constexpr
bool is_clock_v<gps_clock> =
true;
1216 struct leap_second_info
1218 bool is_leap_second;
1229 class weekday_indexed;
1232 class month_day_last;
1233 class month_weekday;
1234 class month_weekday_last;
1236 class year_month_day;
1237 class year_month_day_last;
1238 class year_month_weekday;
1239 class year_month_weekday_last;
1243 explicit last_spec() =
default;
1245 friend constexpr month_day_last
1248 friend constexpr month_day_last
1249 operator/(last_spec,
int __m) noexcept;
1252 inline constexpr last_spec last{};
1262 __modulo(
long long __n,
unsigned __d)
1267 return (__d + (__n % __d)) % __d;
1270 inline constexpr
unsigned __days_per_month[12]
1271 = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
1285 day(
unsigned __d) noexcept
1290 operator++() noexcept
1297 operator++(
int) noexcept
1305 operator--() noexcept
1312 operator--(
int) noexcept
1320 operator+=(
const days& __d) noexcept
1322 *
this = *
this + __d;
1327 operator-=(
const days& __d) noexcept
1329 *
this = *
this - __d;
1334 operator unsigned() const noexcept
1339 {
return 1 <= _M_d && _M_d <= 31; }
1341 friend constexpr
bool
1342 operator==(
const day& __x,
const day& __y) noexcept
1343 {
return unsigned{__x} ==
unsigned{__y}; }
1345 friend constexpr strong_ordering
1346 operator<=>(
const day& __x,
const day& __y) noexcept
1347 {
return unsigned{__x} <=>
unsigned{__y}; }
1349 friend constexpr day
1350 operator+(
const day& __x,
const days& __y) noexcept
1351 {
return day(
unsigned{__x} + __y.count()); }
1353 friend constexpr day
1354 operator+(
const days& __x,
const day& __y) noexcept
1355 {
return __y + __x; }
1357 friend constexpr day
1358 operator-(
const day& __x,
const days& __y) noexcept
1359 {
return __x + -__y; }
1361 friend constexpr days
1362 operator-(
const day& __x,
const day& __y) noexcept
1363 {
return days{int(
unsigned{__x}) -
int(
unsigned{__y})}; }
1365 friend constexpr month_day
1366 operator/(
const month& __m,
const day& __d) noexcept;
1368 friend constexpr month_day
1369 operator/(
int __m,
const day& __d) noexcept;
1371 friend constexpr month_day
1372 operator/(
const day& __d,
const month& __m) noexcept;
1374 friend constexpr month_day
1375 operator/(
const day& __d,
int __m) noexcept;
1377 friend constexpr year_month_day
1378 operator/(
const year_month& __ym,
const day& __d) noexcept;
1394 month(
unsigned __m) noexcept
1399 operator++() noexcept
1406 operator++(
int) noexcept
1414 operator--() noexcept
1421 operator--(
int) noexcept
1429 operator+=(
const months& __m) noexcept
1431 *
this = *
this + __m;
1436 operator-=(
const months& __m) noexcept
1438 *
this = *
this - __m;
1443 operator unsigned() const noexcept
1448 {
return 1 <= _M_m && _M_m <= 12; }
1450 friend constexpr
bool
1451 operator==(
const month& __x,
const month& __y) noexcept
1452 {
return unsigned{__x} ==
unsigned{__y}; }
1454 friend constexpr strong_ordering
1455 operator<=>(
const month& __x,
const month& __y) noexcept
1456 {
return unsigned{__x} <=>
unsigned{__y}; }
1458 friend constexpr month
1459 operator+(
const month& __x,
const months& __y) noexcept
1461 auto __n =
static_cast<long long>(
unsigned{__x}) + (__y.count() - 1);
1462 return month{__detail::__modulo(__n, 12) + 1};
1465 friend constexpr month
1466 operator+(
const months& __x,
const month& __y) noexcept
1467 {
return __y + __x; }
1469 friend constexpr month
1470 operator-(
const month& __x,
const months& __y) noexcept
1471 {
return __x + -__y; }
1473 friend constexpr months
1474 operator-(
const month& __x,
const month& __y) noexcept
1476 const auto __dm = int(
unsigned(__x)) - int(
unsigned(__y));
1477 return months{__dm < 0 ? 12 + __dm : __dm};
1480 friend constexpr year_month
1481 operator/(
const year& __y,
const month& __m) noexcept;
1483 friend constexpr month_day
1484 operator/(
const month& __m,
int __d) noexcept;
1486 friend constexpr month_day_last
1487 operator/(
const month& __m, last_spec) noexcept;
1489 friend constexpr month_day_last
1490 operator/(last_spec, const month& __m) noexcept;
1492 friend constexpr month_weekday
1493 operator/(const month& __m, const weekday_indexed& __wdi) noexcept;
1495 friend constexpr month_weekday
1496 operator/(const weekday_indexed& __wdi, const month& __m) noexcept;
1498 friend constexpr month_weekday_last
1499 operator/(const month& __m, const weekday_last& __wdl) noexcept;
1501 friend constexpr month_weekday_last
1502 operator/(const weekday_last& __wdl, const month& __m) noexcept;
1507 inline constexpr month January{1};
1508 inline constexpr month February{2};
1509 inline constexpr month March{3};
1510 inline constexpr month April{4};
1511 inline constexpr month May{5};
1512 inline constexpr month June{6};
1513 inline constexpr month July{7};
1514 inline constexpr month August{8};
1515 inline constexpr month September{9};
1516 inline constexpr month October{10};
1517 inline constexpr month November{11};
1518 inline constexpr month December{12};
1531 year(
int __y) noexcept
1532 : _M_y{
static_cast<short>(__y)}
1535 static constexpr year
1537 {
return year{-32767}; }
1539 static constexpr year
1541 {
return year{32767}; }
1544 operator++() noexcept
1551 operator++(
int) noexcept
1559 operator--() noexcept
1566 operator--(
int) noexcept
1574 operator+=(
const years& __y) noexcept
1576 *
this = *
this + __y;
1581 operator-=(
const years& __y) noexcept
1583 *
this = *
this - __y;
1593 {
return year{-_M_y}; }
1596 is_leap() const noexcept
1609 constexpr uint32_t __multiplier = 42949673;
1610 constexpr uint32_t __bound = 42949669;
1611 constexpr uint32_t __max_dividend = 1073741799;
1612 constexpr uint32_t __offset = __max_dividend / 2 / 100 * 100;
1613 const bool __is_multiple_of_100
1614 = __multiplier * (_M_y + __offset) < __bound;
1615 return (!__is_multiple_of_100 || _M_y % 400 == 0) && _M_y % 4 == 0;
1619 operator int() const noexcept
1624 {
return min()._M_y <= _M_y && _M_y <=
max()._M_y; }
1626 friend constexpr
bool
1627 operator==(
const year& __x,
const year& __y) noexcept
1628 {
return int{__x} ==
int{__y}; }
1630 friend constexpr strong_ordering
1631 operator<=>(
const year& __x,
const year& __y) noexcept
1632 {
return int{__x} <=>
int{__y}; }
1634 friend constexpr year
1635 operator+(
const year& __x,
const years& __y) noexcept
1636 {
return year{
int{__x} +
static_cast<int>(__y.count())}; }
1638 friend constexpr year
1639 operator+(
const years& __x,
const year& __y) noexcept
1640 {
return __y + __x; }
1642 friend constexpr year
1643 operator-(
const year& __x,
const years& __y) noexcept
1644 {
return __x + -__y; }
1646 friend constexpr years
1647 operator-(
const year& __x,
const year& __y) noexcept
1648 {
return years{
int{__x} -
int{__y}}; }
1650 friend constexpr year_month
1651 operator/(
const year& __y,
int __m) noexcept;
1653 friend constexpr year_month_day
1654 operator/(
const year& __y,
const month_day& __md) noexcept;
1656 friend constexpr year_month_day
1657 operator/(
const month_day& __md,
const year& __y) noexcept;
1659 friend constexpr year_month_day_last
1660 operator/(
const year& __y,
const month_day_last& __mdl) noexcept;
1662 friend constexpr year_month_day_last
1663 operator/(
const month_day_last& __mdl,
const year& __y) noexcept;
1665 friend constexpr year_month_weekday
1666 operator/(
const year& __y,
const month_weekday& __mwd) noexcept;
1668 friend constexpr year_month_weekday
1669 operator/(
const month_weekday& __mwd,
const year& __y) noexcept;
1671 friend constexpr year_month_weekday_last
1672 operator/(
const year& __y,
const month_weekday_last& __mwdl) noexcept;
1674 friend constexpr year_month_weekday_last
1675 operator/(
const month_weekday_last& __mwdl,
const year& __y) noexcept;
1685 unsigned char _M_wd;
1687 static constexpr weekday
1688 _S_from_days(
const days& __d)
1690 auto __n = __d.count();
1691 return weekday(__n >= -4 ? (__n + 4) % 7 : (__n + 5) % 7 + 6);
1695 weekday() =
default;
1698 weekday(
unsigned __wd) noexcept
1699 : _M_wd(__wd == 7 ? 0 : __wd)
1703 weekday(
const sys_days& __dp) noexcept
1704 : weekday{_S_from_days(__dp.time_since_epoch())}
1708 weekday(
const local_days& __dp) noexcept
1709 : weekday{sys_days{__dp.time_since_epoch()}}
1713 operator++() noexcept
1720 operator++(
int) noexcept
1728 operator--() noexcept
1735 operator--(
int) noexcept
1743 operator+=(
const days& __d) noexcept
1745 *
this = *
this + __d;
1750 operator-=(
const days& __d) noexcept
1752 *
this = *
this - __d;
1757 c_encoding() const noexcept
1761 iso_encoding() const noexcept
1762 {
return _M_wd == 0u ? 7u : _M_wd; }
1766 {
return _M_wd <= 6; }
1768 constexpr weekday_indexed
1769 operator[](
unsigned __index)
const noexcept;
1771 constexpr weekday_last
1772 operator[](last_spec) const noexcept;
1774 friend constexpr
bool
1775 operator==(const weekday& __x, const weekday& __y) noexcept
1776 {
return __x._M_wd == __y._M_wd; }
1778 friend constexpr weekday
1779 operator+(
const weekday& __x,
const days& __y) noexcept
1781 auto __n =
static_cast<long long>(__x._M_wd) + __y.count();
1782 return weekday{__detail::__modulo(__n, 7)};
1785 friend constexpr weekday
1786 operator+(
const days& __x,
const weekday& __y) noexcept
1787 {
return __y + __x; }
1789 friend constexpr weekday
1790 operator-(
const weekday& __x,
const days& __y) noexcept
1791 {
return __x + -__y; }
1793 friend constexpr days
1794 operator-(
const weekday& __x,
const weekday& __y) noexcept
1796 auto __n =
static_cast<long long>(__x._M_wd) - __y._M_wd;
1797 return days{__detail::__modulo(__n, 7)};
1803 inline constexpr weekday Sunday{0};
1804 inline constexpr weekday Monday{1};
1805 inline constexpr weekday Tuesday{2};
1806 inline constexpr weekday Wednesday{3};
1807 inline constexpr weekday Thursday{4};
1808 inline constexpr weekday Friday{5};
1809 inline constexpr weekday Saturday{6};
1813 class weekday_indexed
1816 chrono::weekday _M_wd;
1817 unsigned char _M_index;
1820 weekday_indexed() =
default;
1823 weekday_indexed(
const chrono::weekday& __wd,
unsigned __index) noexcept
1824 : _M_wd(__wd), _M_index(__index)
1827 constexpr chrono::weekday
1828 weekday() const noexcept
1832 index() const noexcept
1833 {
return _M_index; };
1837 {
return _M_wd.ok() && 1 <= _M_index && _M_index <= 5; }
1839 friend constexpr
bool
1840 operator==(
const weekday_indexed& __x,
const weekday_indexed& __y) noexcept
1841 {
return __x.weekday() == __y.weekday() && __x.index() == __y.index(); }
1843 friend constexpr month_weekday
1844 operator/(
const month& __m,
const weekday_indexed& __wdi) noexcept;
1846 friend constexpr month_weekday
1847 operator/(
int __m,
const weekday_indexed& __wdi) noexcept;
1849 friend constexpr month_weekday
1850 operator/(
const weekday_indexed& __wdi,
const month& __m) noexcept;
1852 friend constexpr month_weekday
1853 operator/(
const weekday_indexed& __wdi,
int __m) noexcept;
1855 friend constexpr year_month_weekday
1856 operator/(
const year_month& __ym,
const weekday_indexed& __wdi) noexcept;
1861 constexpr weekday_indexed
1862 weekday::operator[](
unsigned __index)
const noexcept
1863 {
return {*
this, __index}; }
1870 chrono::weekday _M_wd;
1874 weekday_last(
const chrono::weekday& __wd) noexcept
1878 constexpr chrono::weekday
1879 weekday() const noexcept
1884 {
return _M_wd.ok(); }
1886 friend constexpr
bool
1887 operator==(
const weekday_last& __x,
const weekday_last& __y) noexcept
1888 {
return __x.weekday() == __y.weekday(); }
1890 friend constexpr month_weekday_last
1891 operator/(
int __m,
const weekday_last& __wdl) noexcept;
1893 friend constexpr month_weekday_last
1894 operator/(
const weekday_last& __wdl,
int __m) noexcept;
1896 friend constexpr year_month_weekday_last
1897 operator/(
const year_month& __ym,
const weekday_last& __wdl) noexcept;
1902 constexpr weekday_last
1903 weekday::operator[](last_spec) const noexcept
1904 {
return weekday_last{*
this}; }
1915 month_day() =
default;
1918 month_day(
const chrono::month& __m,
const chrono::day& __d) noexcept
1919 : _M_m{__m}, _M_d{__d}
1922 constexpr chrono::month
1923 month() const noexcept
1926 constexpr chrono::day
1927 day() const noexcept
1934 && 1u <= unsigned(_M_d)
1935 && unsigned(_M_d) <= __detail::__days_per_month[unsigned(_M_m) - 1];
1938 friend constexpr
bool
1939 operator==(
const month_day& __x,
const month_day& __y) noexcept
1940 {
return __x.month() == __y.month() && __x.day() == __y.day(); }
1942 friend constexpr strong_ordering
1943 operator<=>(
const month_day& __x,
const month_day& __y) noexcept
1946 friend constexpr month_day
1947 operator/(
const chrono::month& __m,
const chrono::day& __d) noexcept
1948 {
return {__m, __d}; }
1950 friend constexpr month_day
1951 operator/(
const chrono::month& __m,
int __d) noexcept
1952 {
return {__m, chrono::day(
unsigned(__d))}; }
1954 friend constexpr month_day
1955 operator/(
int __m,
const chrono::day& __d) noexcept
1956 {
return {chrono::month(
unsigned(__m)), __d}; }
1958 friend constexpr month_day
1959 operator/(
const chrono::day& __d,
const chrono::month& __m) noexcept
1960 {
return {__m, __d}; }
1962 friend constexpr month_day
1963 operator/(
const chrono::day& __d,
int __m) noexcept
1964 {
return {chrono::month(
unsigned(__m)), __d}; }
1966 friend constexpr year_month_day
1967 operator/(
int __y,
const month_day& __md) noexcept;
1969 friend constexpr year_month_day
1970 operator/(
const month_day& __md,
int __y) noexcept;
1977 class month_day_last
1984 month_day_last(
const chrono::month& __m) noexcept
1988 constexpr chrono::month
1989 month() const noexcept
1994 {
return _M_m.ok(); }
1996 friend constexpr
bool
1997 operator==(
const month_day_last& __x,
const month_day_last& __y) noexcept
1998 {
return __x.month() == __y.month(); }
2000 friend constexpr strong_ordering
2001 operator<=>(
const month_day_last& __x,
const month_day_last& __y) noexcept
2004 friend constexpr month_day_last
2005 operator/(
const chrono::month& __m, last_spec) noexcept
2006 {
return month_day_last{__m}; }
2008 friend constexpr month_day_last
2010 {
return chrono::month(
unsigned(__m)) / last; }
2012 friend constexpr month_day_last
2013 operator/(last_spec,
const chrono::month& __m) noexcept
2014 {
return __m / last; }
2016 friend constexpr month_day_last
2018 {
return __m / last; }
2020 friend constexpr year_month_day_last
2021 operator/(
int __y,
const month_day_last& __mdl) noexcept;
2023 friend constexpr year_month_day_last
2024 operator/(
const month_day_last& __mdl,
int __y) noexcept;
2035 chrono::weekday_indexed _M_wdi;
2039 month_weekday(
const chrono::month& __m,
2040 const chrono::weekday_indexed& __wdi) noexcept
2041 : _M_m{__m}, _M_wdi{__wdi}
2044 constexpr chrono::month
2045 month() const noexcept
2048 constexpr chrono::weekday_indexed
2049 weekday_indexed() const noexcept
2054 {
return _M_m.ok() && _M_wdi.ok(); }
2056 friend constexpr
bool
2057 operator==(
const month_weekday& __x,
const month_weekday& __y) noexcept
2059 return __x.month() == __y.month()
2060 && __x.weekday_indexed() == __y.weekday_indexed();
2063 friend constexpr month_weekday
2065 const chrono::weekday_indexed& __wdi) noexcept
2066 {
return {__m, __wdi}; }
2068 friend constexpr month_weekday
2069 operator/(
int __m,
const chrono::weekday_indexed& __wdi) noexcept
2070 {
return chrono::month(
unsigned(__m)) / __wdi; }
2072 friend constexpr month_weekday
2073 operator/(
const chrono::weekday_indexed& __wdi,
2074 const chrono::month& __m) noexcept
2075 {
return __m / __wdi; }
2077 friend constexpr month_weekday
2078 operator/(
const chrono::weekday_indexed& __wdi,
int __m) noexcept
2079 {
return __m / __wdi; }
2081 friend constexpr year_month_weekday
2082 operator/(
int __y,
const month_weekday& __mwd) noexcept;
2084 friend constexpr year_month_weekday
2085 operator/(
const month_weekday& __mwd,
int __y) noexcept;
2092 class month_weekday_last
2096 chrono::weekday_last _M_wdl;
2100 month_weekday_last(
const chrono::month& __m,
2101 const chrono::weekday_last& __wdl) noexcept
2102 :_M_m{__m}, _M_wdl{__wdl}
2105 constexpr chrono::month
2106 month() const noexcept
2109 constexpr chrono::weekday_last
2110 weekday_last() const noexcept
2115 {
return _M_m.ok() && _M_wdl.ok(); }
2117 friend constexpr
bool
2118 operator==(
const month_weekday_last& __x,
2119 const month_weekday_last& __y) noexcept
2121 return __x.month() == __y.month()
2122 && __x.weekday_last() == __y.weekday_last();
2125 friend constexpr month_weekday_last
2127 const chrono::weekday_last& __wdl) noexcept
2128 {
return {__m, __wdl}; }
2130 friend constexpr month_weekday_last
2131 operator/(
int __m,
const chrono::weekday_last& __wdl) noexcept
2132 {
return chrono::month(
unsigned(__m)) / __wdl; }
2134 friend constexpr month_weekday_last
2135 operator/(
const chrono::weekday_last& __wdl,
2136 const chrono::month& __m) noexcept
2137 {
return __m / __wdl; }
2139 friend constexpr month_weekday_last
2140 operator/(
const chrono::weekday_last& __wdl,
int __m) noexcept
2141 {
return chrono::month(
unsigned(__m)) / __wdl; }
2143 friend constexpr year_month_weekday_last
2144 operator/(
int __y,
const month_weekday_last& __mwdl) noexcept;
2146 friend constexpr year_month_weekday_last
2147 operator/(
const month_weekday_last& __mwdl,
int __y) noexcept;
2168 using __months_years_conversion_disambiguator = void;
2178 year_month() =
default;
2181 year_month(
const chrono::year& __y,
const chrono::month& __m) noexcept
2182 : _M_y{__y}, _M_m{__m}
2185 constexpr chrono::year
2186 year() const noexcept
2189 constexpr chrono::month
2190 month() const noexcept
2193 template<
typename = __detail::__months_years_conversion_disambiguator>
2194 constexpr year_month&
2195 operator+=(
const months& __dm) noexcept
2197 *
this = *
this + __dm;
2201 template<
typename = __detail::__months_years_conversion_disambiguator>
2202 constexpr year_month&
2203 operator-=(
const months& __dm) noexcept
2205 *
this = *
this - __dm;
2209 constexpr year_month&
2210 operator+=(
const years& __dy) noexcept
2212 *
this = *
this + __dy;
2216 constexpr year_month&
2217 operator-=(
const years& __dy) noexcept
2219 *
this = *
this - __dy;
2225 {
return _M_y.ok() && _M_m.ok(); }
2227 friend constexpr
bool
2228 operator==(
const year_month& __x,
const year_month& __y) noexcept
2229 {
return __x.year() == __y.year() && __x.month() == __y.month(); }
2231 friend constexpr strong_ordering
2232 operator<=>(
const year_month& __x,
const year_month& __y) noexcept
2235 template<
typename = __detail::__months_years_conversion_disambiguator>
2236 friend constexpr year_month
2237 operator+(
const year_month& __ym,
const months& __dm) noexcept
2240 auto __m = __ym.month() + __dm;
2241 auto __i = int(
unsigned(__ym.month())) - 1 + __dm.count();
2243 ? __ym.year() + years{(__i - 11) / 12}
2244 : __ym.year() + years{__i / 12});
2248 template<
typename = __detail::__months_years_conversion_disambiguator>
2249 friend constexpr year_month
2250 operator+(
const months& __dm,
const year_month& __ym) noexcept
2251 {
return __ym + __dm; }
2253 template<
typename = __detail::__months_years_conversion_disambiguator>
2254 friend constexpr year_month
2255 operator-(
const year_month& __ym,
const months& __dm) noexcept
2256 {
return __ym + -__dm; }
2258 friend constexpr months
2259 operator-(
const year_month& __x,
const year_month& __y) noexcept
2261 return (__x.year() - __y.year()
2262 + months{
static_cast<int>(
unsigned{__x.month()})
2263 - static_cast<int>(
unsigned{__y.month()})});
2266 friend constexpr year_month
2267 operator+(
const year_month& __ym,
const years& __dy) noexcept
2268 {
return (__ym.year() + __dy) / __ym.month(); }
2270 friend constexpr year_month
2271 operator+(
const years& __dy,
const year_month& __ym) noexcept
2272 {
return __ym + __dy; }
2274 friend constexpr year_month
2275 operator-(
const year_month& __ym,
const years& __dy) noexcept
2276 {
return __ym + -__dy; }
2278 friend constexpr year_month
2279 operator/(
const chrono::year& __y,
const chrono::month& __m) noexcept
2280 {
return {__y, __m}; }
2282 friend constexpr year_month
2283 operator/(
const chrono::year& __y,
int __m) noexcept
2284 {
return {__y, chrono::month(
unsigned(__m))}; }
2286 friend constexpr year_month_day
2287 operator/(
const year_month& __ym,
int __d) noexcept;
2289 friend constexpr year_month_day_last
2290 operator/(
const year_month& __ym, last_spec) noexcept;
2297 class year_month_day
2304 static constexpr year_month_day _S_from_days(
const days& __dp) noexcept;
2306 constexpr days _M_days_since_epoch() const noexcept;
2309 year_month_day() = default;
2312 year_month_day(const chrono::year& __y, const chrono::month& __m,
2313 const chrono::day& __d) noexcept
2314 : _M_y{__y}, _M_m{__m}, _M_d{__d}
2318 year_month_day(
const year_month_day_last& __ymdl) noexcept;
2321 year_month_day(
const sys_days& __dp) noexcept
2322 : year_month_day(_S_from_days(__dp.time_since_epoch()))
2326 year_month_day(
const local_days& __dp) noexcept
2327 : year_month_day(sys_days{__dp.time_since_epoch()})
2330 template<
typename = __detail::__months_years_conversion_disambiguator>
2331 constexpr year_month_day&
2332 operator+=(
const months& __m) noexcept
2334 *
this = *
this + __m;
2338 template<
typename = __detail::__months_years_conversion_disambiguator>
2339 constexpr year_month_day&
2340 operator-=(
const months& __m) noexcept
2342 *
this = *
this - __m;
2346 constexpr year_month_day&
2347 operator+=(
const years& __y) noexcept
2349 *
this = *
this + __y;
2353 constexpr year_month_day&
2354 operator-=(
const years& __y) noexcept
2356 *
this = *
this - __y;
2360 constexpr chrono::year
2361 year() const noexcept
2364 constexpr chrono::month
2365 month() const noexcept
2368 constexpr chrono::day
2369 day() const noexcept
2373 operator sys_days() const noexcept
2374 {
return sys_days{_M_days_since_epoch()}; }
2377 operator local_days() const noexcept
2378 {
return local_days{sys_days{*
this}.time_since_epoch()}; }
2380 constexpr
bool ok() const noexcept;
2382 friend constexpr
bool
2383 operator==(const year_month_day& __x, const year_month_day& __y) noexcept
2385 return __x.year() == __y.year()
2386 && __x.month() == __y.month()
2387 && __x.day() == __y.day();
2390 friend constexpr strong_ordering
2391 operator<=>(
const year_month_day& __x,
const year_month_day& __y) noexcept
2394 template<
typename = __detail::__months_years_conversion_disambiguator>
2395 friend constexpr year_month_day
2396 operator+(
const year_month_day& __ymd,
const months& __dm) noexcept
2397 {
return (__ymd.year() / __ymd.month() + __dm) / __ymd.day(); }
2399 template<
typename = __detail::__months_years_conversion_disambiguator>
2400 friend constexpr year_month_day
2401 operator+(
const months& __dm,
const year_month_day& __ymd) noexcept
2402 {
return __ymd + __dm; }
2404 friend constexpr year_month_day
2405 operator+(
const year_month_day& __ymd,
const years& __dy) noexcept
2406 {
return (__ymd.year() + __dy) / __ymd.month() / __ymd.day(); }
2408 friend constexpr year_month_day
2409 operator+(
const years& __dy,
const year_month_day& __ymd) noexcept
2410 {
return __ymd + __dy; }
2412 template<
typename = __detail::__months_years_conversion_disambiguator>
2413 friend constexpr year_month_day
2414 operator-(
const year_month_day& __ymd,
const months& __dm) noexcept
2415 {
return __ymd + -__dm; }
2417 friend constexpr year_month_day
2418 operator-(
const year_month_day& __ymd,
const years& __dy) noexcept
2419 {
return __ymd + -__dy; }
2421 friend constexpr year_month_day
2422 operator/(
const year_month& __ym,
const chrono::day& __d) noexcept
2423 {
return {__ym.year(), __ym.month(), __d}; }
2425 friend constexpr year_month_day
2426 operator/(
const year_month& __ym,
int __d) noexcept
2427 {
return __ym / chrono::day{unsigned(__d)}; }
2429 friend constexpr year_month_day
2430 operator/(
const chrono::year& __y,
const month_day& __md) noexcept
2431 {
return __y / __md.month() / __md.day(); }
2433 friend constexpr year_month_day
2434 operator/(
int __y,
const month_day& __md) noexcept
2435 {
return chrono::year{__y} / __md; }
2437 friend constexpr year_month_day
2438 operator/(
const month_day& __md,
const chrono::year& __y) noexcept
2439 {
return __y / __md; }
2441 friend constexpr year_month_day
2442 operator/(
const month_day& __md,
int __y) noexcept
2443 {
return chrono::year(__y) / __md; }
2452 constexpr year_month_day
2453 year_month_day::_S_from_days(
const days& __dp) noexcept
2455 constexpr
auto __z2 =
static_cast<uint32_t
>(-1468000);
2456 constexpr
auto __r2_e3 =
static_cast<uint32_t
>(536895458);
2458 const auto __r0 =
static_cast<uint32_t
>(__dp.count()) + __r2_e3;
2460 const auto __n1 = 4 * __r0 + 3;
2461 const auto __q1 = __n1 / 146097;
2462 const auto __r1 = __n1 % 146097 / 4;
2464 constexpr
auto __p32 =
static_cast<uint64_t
>(1) << 32;
2465 const auto __n2 = 4 * __r1 + 3;
2466 const auto __u2 =
static_cast<uint64_t
>(2939745) * __n2;
2467 const auto __q2 =
static_cast<uint32_t
>(__u2 / __p32);
2468 const auto __r2 =
static_cast<uint32_t
>(__u2 % __p32) / 2939745 / 4;
2470 constexpr
auto __p16 =
static_cast<uint32_t
>(1) << 16;
2471 const auto __n3 = 2141 * __r2 + 197913;
2472 const auto __q3 = __n3 / __p16;
2473 const auto __r3 = __n3 % __p16 / 2141;
2475 const auto __y0 = 100 * __q1 + __q2;
2476 const auto __m0 = __q3;
2477 const auto __d0 = __r3;
2479 const auto __j = __r2 >= 306;
2480 const auto __y1 = __y0 + __j;
2481 const auto __m1 = __j ? __m0 - 12 : __m0;
2482 const auto __d1 = __d0 + 1;
2484 return year_month_day{chrono::year{
static_cast<int>(__y1 + __z2)},
2485 chrono::month{__m1}, chrono::day{__d1}};
2493 year_month_day::_M_days_since_epoch() const noexcept
2495 auto constexpr __z2 =
static_cast<uint32_t
>(-1468000);
2496 auto constexpr __r2_e3 =
static_cast<uint32_t
>(536895458);
2498 const auto __y1 =
static_cast<uint32_t
>(
static_cast<int>(_M_y)) - __z2;
2499 const auto __m1 =
static_cast<uint32_t
>(
static_cast<unsigned>(_M_m));
2500 const auto __d1 =
static_cast<uint32_t
>(
static_cast<unsigned>(_M_d));
2502 const auto __j =
static_cast<uint32_t
>(__m1 < 3);
2503 const auto __y0 = __y1 - __j;
2504 const auto __m0 = __j ? __m1 + 12 : __m1;
2505 const auto __d0 = __d1 - 1;
2507 const auto __q1 = __y0 / 100;
2508 const auto __yc = 1461 * __y0 / 4 - __q1 + __q1 / 4;
2509 const auto __mc = (979 *__m0 - 2919) / 32;
2510 const auto __dc = __d0;
2512 return days{
static_cast<int32_t
>(__yc + __mc + __dc - __r2_e3)};
2517 class year_month_day_last
2521 chrono::month_day_last _M_mdl;
2525 year_month_day_last(
const chrono::year& __y,
2526 const chrono::month_day_last& __mdl) noexcept
2527 : _M_y{__y}, _M_mdl{__mdl}
2530 template<
typename = __detail::__months_years_conversion_disambiguator>
2531 constexpr year_month_day_last&
2532 operator+=(
const months& __m) noexcept
2534 *
this = *
this + __m;
2538 template<
typename = __detail::__months_years_conversion_disambiguator>
2539 constexpr year_month_day_last&
2540 operator-=(
const months& __m) noexcept
2542 *
this = *
this - __m;
2546 constexpr year_month_day_last&
2547 operator+=(
const years& __y) noexcept
2549 *
this = *
this + __y;
2553 constexpr year_month_day_last&
2554 operator-=(
const years& __y) noexcept
2556 *
this = *
this - __y;
2560 constexpr chrono::year
2561 year() const noexcept
2564 constexpr chrono::month
2565 month() const noexcept
2566 {
return _M_mdl.month(); }
2568 constexpr chrono::month_day_last
2569 month_day_last() const noexcept
2573 constexpr chrono::day
2574 day() const noexcept
2576 const auto __m =
static_cast<unsigned>(month());
2592 return chrono::day{__m != 2 ? ((__m ^ (__m >> 3)) & 1) | 30
2593 : _M_y.is_leap() ? 29 : 28};
2597 operator sys_days() const noexcept
2598 {
return sys_days{year() / month() / day()}; }
2601 operator local_days() const noexcept
2602 {
return local_days{sys_days{*
this}.time_since_epoch()}; }
2606 {
return _M_y.ok() && _M_mdl.ok(); }
2608 friend constexpr
bool
2609 operator==(
const year_month_day_last& __x,
2610 const year_month_day_last& __y) noexcept
2612 return __x.year() == __y.year()
2613 && __x.month_day_last() == __y.month_day_last();
2616 friend constexpr strong_ordering
2617 operator<=>(
const year_month_day_last& __x,
2618 const year_month_day_last& __y) noexcept
2621 template<
typename = __detail::__months_years_conversion_disambiguator>
2622 friend constexpr year_month_day_last
2623 operator+(
const year_month_day_last& __ymdl,
2624 const months& __dm) noexcept
2625 {
return (__ymdl.year() / __ymdl.month() + __dm) / last; }
2627 template<
typename = __detail::__months_years_conversion_disambiguator>
2628 friend constexpr year_month_day_last
2630 const year_month_day_last& __ymdl) noexcept
2631 {
return __ymdl + __dm; }
2633 template<
typename = __detail::__months_years_conversion_disambiguator>
2634 friend constexpr year_month_day_last
2635 operator-(
const year_month_day_last& __ymdl,
2636 const months& __dm) noexcept
2637 {
return __ymdl + -__dm; }
2639 friend constexpr year_month_day_last
2640 operator+(
const year_month_day_last& __ymdl,
2641 const years& __dy) noexcept
2642 {
return {__ymdl.year() + __dy, __ymdl.month_day_last()}; }
2644 friend constexpr year_month_day_last
2646 const year_month_day_last& __ymdl) noexcept
2647 {
return __ymdl + __dy; }
2649 friend constexpr year_month_day_last
2650 operator-(
const year_month_day_last& __ymdl,
2651 const years& __dy) noexcept
2652 {
return __ymdl + -__dy; }
2654 friend constexpr year_month_day_last
2655 operator/(
const year_month& __ym, last_spec) noexcept
2656 {
return {__ym.year(), chrono::month_day_last{__ym.month()}}; }
2658 friend constexpr year_month_day_last
2660 const chrono::month_day_last& __mdl) noexcept
2661 {
return {__y, __mdl}; }
2663 friend constexpr year_month_day_last
2664 operator/(
int __y,
const chrono::month_day_last& __mdl) noexcept
2665 {
return chrono::year(__y) / __mdl; }
2667 friend constexpr year_month_day_last
2668 operator/(
const chrono::month_day_last& __mdl,
2669 const chrono::year& __y) noexcept
2670 {
return __y / __mdl; }
2672 friend constexpr year_month_day_last
2673 operator/(
const chrono::month_day_last& __mdl,
int __y) noexcept
2674 {
return chrono::year(__y) / __mdl; }
2681 year_month_day::year_month_day(
const year_month_day_last& __ymdl) noexcept
2682 : _M_y{__ymdl.year()}, _M_m{__ymdl.month()}, _M_d{__ymdl.day()}
2686 year_month_day::ok() const noexcept
2688 if (!_M_y.ok() || !_M_m.ok())
2690 return chrono::day{1} <= _M_d && _M_d <= (_M_y / _M_m / last).day();
2695 class year_month_weekday
2700 chrono::weekday_indexed _M_wdi;
2702 static constexpr year_month_weekday
2703 _S_from_sys_days(
const sys_days& __dp)
2705 year_month_day __ymd{__dp};
2706 chrono::weekday __wd{__dp};
2707 auto __index = __wd[(
unsigned{__ymd.day()} - 1) / 7 + 1];
2708 return {__ymd.year(), __ymd.month(), __index};
2712 year_month_weekday() =
default;
2715 year_month_weekday(
const chrono::year& __y,
const chrono::month& __m,
2716 const chrono::weekday_indexed& __wdi) noexcept
2717 : _M_y{__y}, _M_m{__m}, _M_wdi{__wdi}
2721 year_month_weekday(
const sys_days& __dp) noexcept
2722 : year_month_weekday{_S_from_sys_days(__dp)}
2726 year_month_weekday(
const local_days& __dp) noexcept
2727 : year_month_weekday{sys_days{__dp.time_since_epoch()}}
2730 template<
typename = __detail::__months_years_conversion_disambiguator>
2731 constexpr year_month_weekday&
2732 operator+=(
const months& __m) noexcept
2734 *
this = *
this + __m;
2738 template<
typename = __detail::__months_years_conversion_disambiguator>
2739 constexpr year_month_weekday&
2740 operator-=(
const months& __m) noexcept
2742 *
this = *
this - __m;
2746 constexpr year_month_weekday&
2747 operator+=(
const years& __y) noexcept
2749 *
this = *
this + __y;
2753 constexpr year_month_weekday&
2754 operator-=(
const years& __y) noexcept
2756 *
this = *
this - __y;
2760 constexpr chrono::year
2761 year() const noexcept
2764 constexpr chrono::month
2765 month() const noexcept
2768 constexpr chrono::weekday
2769 weekday() const noexcept
2770 {
return _M_wdi.weekday(); }
2773 index() const noexcept
2774 {
return _M_wdi.index(); }
2776 constexpr chrono::weekday_indexed
2777 weekday_indexed() const noexcept
2781 operator sys_days() const noexcept
2783 auto __d = sys_days{year() / month() / 1};
2784 return __d + (weekday() - chrono::weekday(__d)
2785 + days{(
static_cast<int>(index())-1)*7});
2789 operator local_days() const noexcept
2790 {
return local_days{sys_days{*
this}.time_since_epoch()}; }
2795 if (!_M_y.ok() || !_M_m.ok() || !_M_wdi.ok())
2797 if (_M_wdi.index() <= 4)
2799 days __d = (_M_wdi.weekday()
2800 - chrono::weekday{sys_days{_M_y / _M_m / 1}}
2801 + days((_M_wdi.index()-1)*7 + 1));
2802 __glibcxx_assert(__d.count() >= 1);
2803 return __d.count() <=
unsigned{(_M_y / _M_m / last).day()};
2806 friend constexpr
bool
2807 operator==(
const year_month_weekday& __x,
2808 const year_month_weekday& __y) noexcept
2810 return __x.year() == __y.year()
2811 && __x.month() == __y.month()
2812 && __x.weekday_indexed() == __y.weekday_indexed();
2815 template<
typename = __detail::__months_years_conversion_disambiguator>
2816 friend constexpr year_month_weekday
2817 operator+(
const year_month_weekday& __ymwd,
const months& __dm) noexcept
2819 return ((__ymwd.year() / __ymwd.month() + __dm)
2820 / __ymwd.weekday_indexed());
2823 template<
typename = __detail::__months_years_conversion_disambiguator>
2824 friend constexpr year_month_weekday
2825 operator+(
const months& __dm,
const year_month_weekday& __ymwd) noexcept
2826 {
return __ymwd + __dm; }
2828 friend constexpr year_month_weekday
2829 operator+(
const year_month_weekday& __ymwd,
const years& __dy) noexcept
2830 {
return {__ymwd.year() + __dy, __ymwd.month(), __ymwd.weekday_indexed()}; }
2832 friend constexpr year_month_weekday
2833 operator+(
const years& __dy,
const year_month_weekday& __ymwd) noexcept
2834 {
return __ymwd + __dy; }
2836 template<
typename = __detail::__months_years_conversion_disambiguator>
2837 friend constexpr year_month_weekday
2838 operator-(
const year_month_weekday& __ymwd,
const months& __dm) noexcept
2839 {
return __ymwd + -__dm; }
2841 friend constexpr year_month_weekday
2842 operator-(
const year_month_weekday& __ymwd,
const years& __dy) noexcept
2843 {
return __ymwd + -__dy; }
2845 friend constexpr year_month_weekday
2847 const chrono::weekday_indexed& __wdi) noexcept
2848 {
return {__ym.year(), __ym.month(), __wdi}; }
2850 friend constexpr year_month_weekday
2851 operator/(
const chrono::year& __y,
const month_weekday& __mwd) noexcept
2852 {
return {__y, __mwd.month(), __mwd.weekday_indexed()}; }
2854 friend constexpr year_month_weekday
2855 operator/(
int __y,
const month_weekday& __mwd) noexcept
2856 {
return chrono::year(__y) / __mwd; }
2858 friend constexpr year_month_weekday
2859 operator/(
const month_weekday& __mwd,
const chrono::year& __y) noexcept
2860 {
return __y / __mwd; }
2862 friend constexpr year_month_weekday
2863 operator/(
const month_weekday& __mwd,
int __y) noexcept
2864 {
return chrono::year(__y) / __mwd; }
2871 class year_month_weekday_last
2876 chrono::weekday_last _M_wdl;
2880 year_month_weekday_last(
const chrono::year& __y,
const chrono::month& __m,
2881 const chrono::weekday_last& __wdl) noexcept
2882 : _M_y{__y}, _M_m{__m}, _M_wdl{__wdl}
2885 template<
typename = __detail::__months_years_conversion_disambiguator>
2886 constexpr year_month_weekday_last&
2887 operator+=(
const months& __m) noexcept
2889 *
this = *
this + __m;
2893 template<
typename = __detail::__months_years_conversion_disambiguator>
2894 constexpr year_month_weekday_last&
2895 operator-=(
const months& __m) noexcept
2897 *
this = *
this - __m;
2901 constexpr year_month_weekday_last&
2902 operator+=(
const years& __y) noexcept
2904 *
this = *
this + __y;
2908 constexpr year_month_weekday_last&
2909 operator-=(
const years& __y) noexcept
2911 *
this = *
this - __y;
2915 constexpr chrono::year
2916 year() const noexcept
2919 constexpr chrono::month
2920 month() const noexcept
2923 constexpr chrono::weekday
2924 weekday() const noexcept
2925 {
return _M_wdl.weekday(); }
2927 constexpr chrono::weekday_last
2928 weekday_last() const noexcept
2932 operator sys_days() const noexcept
2934 const auto __d = sys_days{_M_y / _M_m / last};
2935 return sys_days{(__d - (chrono::weekday{__d}
2936 - _M_wdl.weekday())).time_since_epoch()};
2940 operator local_days() const noexcept
2941 {
return local_days{sys_days{*
this}.time_since_epoch()}; }
2945 {
return _M_y.ok() && _M_m.ok() && _M_wdl.ok(); }
2947 friend constexpr
bool
2948 operator==(
const year_month_weekday_last& __x,
2949 const year_month_weekday_last& __y) noexcept
2951 return __x.year() == __y.year()
2952 && __x.month() == __y.month()
2953 && __x.weekday_last() == __y.weekday_last();
2956 template<
typename = __detail::__months_years_conversion_disambiguator>
2957 friend constexpr year_month_weekday_last
2958 operator+(
const year_month_weekday_last& __ymwdl,
2959 const months& __dm) noexcept
2961 return ((__ymwdl.year() / __ymwdl.month() + __dm)
2962 / __ymwdl.weekday_last());
2965 template<
typename = __detail::__months_years_conversion_disambiguator>
2966 friend constexpr year_month_weekday_last
2968 const year_month_weekday_last& __ymwdl) noexcept
2969 {
return __ymwdl + __dm; }
2971 friend constexpr year_month_weekday_last
2972 operator+(
const year_month_weekday_last& __ymwdl,
2973 const years& __dy) noexcept
2974 {
return {__ymwdl.year() + __dy, __ymwdl.month(), __ymwdl.weekday_last()}; }
2976 friend constexpr year_month_weekday_last
2978 const year_month_weekday_last& __ymwdl) noexcept
2979 {
return __ymwdl + __dy; }
2981 template<
typename = __detail::__months_years_conversion_disambiguator>
2982 friend constexpr year_month_weekday_last
2983 operator-(
const year_month_weekday_last& __ymwdl,
2984 const months& __dm) noexcept
2985 {
return __ymwdl + -__dm; }
2987 friend constexpr year_month_weekday_last
2988 operator-(
const year_month_weekday_last& __ymwdl,
2989 const years& __dy) noexcept
2990 {
return __ymwdl + -__dy; }
2992 friend constexpr year_month_weekday_last
2994 const chrono::weekday_last& __wdl) noexcept
2995 {
return {__ym.year(), __ym.month(), __wdl}; }
2997 friend constexpr year_month_weekday_last
2999 const chrono::month_weekday_last& __mwdl) noexcept
3000 {
return {__y, __mwdl.month(), __mwdl.weekday_last()}; }
3002 friend constexpr year_month_weekday_last
3003 operator/(
int __y,
const chrono::month_weekday_last& __mwdl) noexcept
3004 {
return chrono::year(__y) / __mwdl; }
3006 friend constexpr year_month_weekday_last
3007 operator/(
const chrono::month_weekday_last& __mwdl,
3008 const chrono::year& __y) noexcept
3009 {
return __y / __mwdl; }
3011 friend constexpr year_month_weekday_last
3012 operator/(
const chrono::month_weekday_last& __mwdl,
int __y) noexcept
3013 {
return chrono::year(__y) / __mwdl; }
3023 __pow10(
unsigned __n)
3032 template<
typename _Duration>
3036 static constexpr
int
3037 _S_fractional_width()
3039 int __multiplicity_2 = 0;
3040 int __multiplicity_5 = 0;
3041 auto __den = _Duration::period::den;
3042 while ((__den % 2) == 0)
3047 while ((__den % 5) == 0)
3055 int __width = (__multiplicity_2 > __multiplicity_5
3056 ? __multiplicity_2 : __multiplicity_5);
3063 static constexpr
unsigned fractional_width = {_S_fractional_width()};
3067 chrono::seconds::rep>,
3068 ratio<1, __detail::__pow10(fractional_width)>>;
3072 : hh_mm_ss{_Duration::zero()}
3076 hh_mm_ss(_Duration __d) noexcept
3077 : _M_is_neg (__d < _Duration::zero()),
3078 _M_h (duration_cast<chrono::hours>(abs(__d))),
3079 _M_m (duration_cast<chrono::minutes>(abs(__d) -
hours())),
3080 _M_s (duration_cast<chrono::seconds>(abs(__d) -
hours() -
minutes()))
3082 if constexpr (treat_as_floating_point_v<typename precision::rep>)
3090 is_negative() const noexcept
3091 {
return _M_is_neg; }
3094 hours() const noexcept
3106 subseconds() const noexcept
3110 operator precision() const noexcept
3111 {
return to_duration(); }
3114 to_duration() const noexcept
3117 return -(_M_h + _M_m + _M_s + _M_ss);
3119 return _M_h + _M_m + _M_s + _M_ss;
3136 #if __cplusplus > 201103L
3138 #define __cpp_lib_chrono_udls 201304
3140 inline namespace literals
3165 inline namespace chrono_literals
3167 #pragma GCC diagnostic push
3168 #pragma GCC diagnostic ignored "-Wliteral-suffix"
3170 template<
typename _Dur,
char... _Digits>
3171 constexpr _Dur __check_overflow()
3173 using _Val = __parse_int::_Parse_int<_Digits...>;
3174 constexpr
typename _Dur::rep __repval = _Val::value;
3175 static_assert(__repval >= 0 && __repval == _Val::value,
3176 "literal value cannot be represented by duration type");
3177 return _Dur(__repval);
3183 operator""h(
long double __hours)
3187 template <
char... _Digits>
3194 operator""min(
long double __mins)
3198 template <
char... _Digits>
3205 operator""s(
long double __secs)
3209 template <
char... _Digits>
3216 operator""ms(
long double __msecs)
3220 template <
char... _Digits>
3227 operator""us(
long double __usecs)
3231 template <
char... _Digits>
3238 operator""ns(
long double __nsecs)
3242 template <
char... _Digits>
3247 #if __cplusplus > 201703L
3248 constexpr chrono::day
3249 operator""d(
unsigned long long __d) noexcept
3250 {
return chrono::day{
static_cast<unsigned>(__d)}; }
3252 constexpr chrono::year
3253 operator""y(
unsigned long long __y) noexcept
3254 {
return chrono::year{
static_cast<int>(__y)}; }
3257 #pragma GCC diagnostic pop
3263 using namespace literals::chrono_literals;
3266 #if __cplusplus > 201703L
3272 is_am(
const hours& __h) noexcept
3273 {
return 0h <= __h && __h <= 11h; }
3276 is_pm(
const hours& __h) noexcept
3277 {
return 12h <= __h && __h <= 23h; }
3280 make12(
const hours& __h) noexcept
3290 make24(
const hours& __h,
bool __is_pm) noexcept
3310 #if __cplusplus >= 201703L
3311 namespace filesystem
3316 using rep = duration::rep;
3317 using period = duration::period;
3318 using time_point = chrono::time_point<__file_clock>;
3319 static constexpr
bool is_steady =
false;
3323 {
return _S_from_sys(chrono::system_clock::now()); }
3325 #if __cplusplus > 201703L
3326 template<
typename _Dur>
3328 chrono::file_time<_Dur>
3329 from_sys(
const chrono::sys_time<_Dur>& __t) noexcept
3330 {
return _S_from_sys(__t); }
3333 template<
typename _Dur>
3335 chrono::sys_time<_Dur>
3336 to_sys(
const chrono::file_time<_Dur>& __t) noexcept
3337 {
return _S_to_sys(__t); }
3341 using __sys_clock = chrono::system_clock;
3350 template<
typename _Dur>
3352 chrono::time_point<__file_clock, _Dur>
3353 _S_from_sys(
const chrono::time_point<__sys_clock, _Dur>& __t) noexcept
3355 using __file_time = chrono::time_point<__file_clock, _Dur>;
3356 return __file_time{__t.time_since_epoch()} - _S_epoch_diff;
3360 template<
typename _Dur>
3362 chrono::time_point<__sys_clock, _Dur>
3363 _S_to_sys(
const chrono::time_point<__file_clock, _Dur>& __t) noexcept
3365 using __sys_time = chrono::time_point<__sys_clock, _Dur>;
3366 return __sys_time{__t.time_since_epoch()} + _S_epoch_diff;
3373 _GLIBCXX_END_NAMESPACE_VERSION
3378 #endif //_GLIBCXX_CHRONO
constexpr enable_if< __is_duration< _ToDur >::value, time_point< _Clock, _ToDur > >::type time_point_cast(const time_point< _Clock, _Dur > &__t)
time_point_cast
constexpr time_point< _Clock, typename common_type< duration< _Rep1, _Period1 >, _Dur2 >::type > operator+(const duration< _Rep1, _Period1 > &__lhs, const time_point< _Clock, _Dur2 > &__rhs)
Adjust a time point forwards by the given duration.
static constexpr _Tp max() noexcept
typename enable_if< _Cond, _Tp >::type enable_if_t
Alias template for enable_if.
constexpr const _Tp & min(const _Tp &, const _Tp &)
This does what you think it does.
integral_constant< bool, true > true_type
The type used as a compile-time boolean with true value.
constexpr time_point< _Clock, typename common_type< _Dur1, duration< _Rep2, _Period2 > >::type > operator-(const time_point< _Clock, _Dur1 > &__lhs, const duration< _Rep2, _Period2 > &__rhs)
Adjust a time point backwards by the given duration.
duration< int64_t, ratio< 60 >> minutes
minutes
typename __ratio_divide< _R1, _R2 >::type ratio_divide
ratio_divide
constexpr complex< _Tp > operator/(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x divided by y.
constexpr common_type< duration< _Rep1, _Period1 >, duration< _Rep2, _Period2 > >::type operator+(const duration< _Rep1, _Period1 > &__lhs, const duration< _Rep2, _Period2 > &__rhs)
The sum of two durations.
static constexpr _Tp lowest() noexcept
constexpr duration< __common_rep_t< _Rep2, _Rep1 >, _Period > operator*(const _Rep1 &__s, const duration< _Rep2, _Period > &__d)
Multiply a duration by a scalar value.
constexpr duration< __common_rep_t< _Rep1, _Rep2 >, _Period > operator*(const duration< _Rep1, _Period > &__d, const _Rep2 &__s)
Multiply a duration by a scalar value.
constexpr common_type< _Dur1, _Dur2 >::type operator-(const time_point< _Clock, _Dur1 > &__lhs, const time_point< _Clock, _Dur2 > &__rhs)
The difference between two time points (as a duration)
duration< int64_t, nano > nanoseconds
nanoseconds
duration< int64_t, milli > milliseconds
milliseconds
constexpr common_type< duration< _Rep1, _Period1 >, duration< _Rep2, _Period2 > >::type operator-(const duration< _Rep1, _Period1 > &__lhs, const duration< _Rep2, _Period2 > &__rhs)
The difference between two durations.
Properties of fundamental types.
constexpr complex< _Tp > operator+(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x plus y.
duration< int64_t, micro > microseconds
microseconds
duration< int64_t, ratio< 3600 >> hours
hours
integral_constant< bool, false > false_type
The type used as a compile-time boolean with false value.
constexpr complex< _Tp > operator-(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x minus y.
Define a member typedef type only if a boolean constant is true.
duration< int64_t > seconds
seconds
constexpr __enable_if_is_duration< _ToDur > duration_cast(const duration< _Rep, _Period > &__d)
duration_cast
constexpr const _Tp & max(const _Tp &, const _Tp &)
This does what you think it does.
typename common_type< _Tp...>::type common_type_t
Alias template for common_type.
Provides compile-time rational arithmetic.
constexpr time_point< _Clock, typename common_type< _Dur1, duration< _Rep2, _Period2 > >::type > operator+(const time_point< _Clock, _Dur1 > &__lhs, const duration< _Rep2, _Period2 > &__rhs)
Adjust a time point forwards by the given duration.
void void_t
A metafunction that always yields void, used for detecting valid types.