30#ifndef _GLIBCXX_CHRONO_H
31#define _GLIBCXX_CHRONO_H 1
34#pragma GCC system_header
37#if __cplusplus >= 201103L
46#if __cplusplus >= 202002L
53namespace std _GLIBCXX_VISIBILITY(default)
55_GLIBCXX_BEGIN_NAMESPACE_VERSION
57#if __cplusplus >= 201703L && _GLIBCXX_HOSTED
67 template<
typename _Rep,
typename _Period = ratio<1>>
71 template<
typename _Clock,
typename _Dur =
typename _Clock::duration>
83 template<
typename _CT,
typename _Period1,
typename _Period2,
typename =
void>
84 struct __duration_common_type
87 template<
typename _CT,
typename _Period1,
typename _Period2>
88 struct __duration_common_type<_CT, _Period1, _Period2,
89 __void_t<typename _CT::type>>
92 using __gcd_num = __static_gcd<_Period1::num, _Period2::num>;
93 using __gcd_den = __static_gcd<_Period1::den, _Period2::den>;
94 using __cr =
typename _CT::type;
95 using __r = ratio<__gcd_num::value,
96 (_Period1::den / __gcd_den::value) * _Period2::den>;
99 using type = chrono::duration<__cr, typename __r::type>;
108 template<
typename _Rep1,
typename _Period1,
typename _Rep2,
typename _Period2>
111 : __duration_common_type<common_type<_Rep1, _Rep2>,
112 typename _Period1::type,
113 typename _Period2::type>
117 template<
typename _Rep,
typename _Period>
122 typename _Period::type>;
126 template<
typename _Rep,
typename _Period>
130 typename _Period::type>;
138 template<
typename _CT,
typename _Clock,
typename =
void>
139 struct __timepoint_common_type
142 template<
typename _CT,
typename _Clock>
143 struct __timepoint_common_type<_CT, _Clock, __void_t<typename _CT::type>>
145 using type = chrono::time_point<_Clock, typename _CT::type>;
154 template<
typename _Clock,
typename _Duration1,
typename _Duration2>
157 : __timepoint_common_type<common_type<_Duration1, _Duration2>, _Clock>
161 template<
typename _Clock,
typename _Duration>
167 template<
typename _Clock,
typename _Duration>
182 template<
typename _ToDur,
typename _CF,
typename _CR,
183 bool _NumIsOne =
false,
bool _DenIsOne =
false>
184 struct __duration_cast_impl
186 template<
typename _Rep,
typename _Period>
187 static constexpr _ToDur
188 __cast(
const duration<_Rep, _Period>& __d)
190 typedef typename _ToDur::rep __to_rep;
191 return _ToDur(
static_cast<__to_rep
>(
static_cast<_CR
>(__d.count())
192 *
static_cast<_CR
>(_CF::num)
193 /
static_cast<_CR
>(_CF::den)));
197 template<
typename _ToDur,
typename _CF,
typename _CR>
198 struct __duration_cast_impl<_ToDur, _CF, _CR, true, true>
200 template<
typename _Rep,
typename _Period>
201 static constexpr _ToDur
202 __cast(
const duration<_Rep, _Period>& __d)
204 typedef typename _ToDur::rep __to_rep;
205 return _ToDur(
static_cast<__to_rep
>(__d.count()));
209 template<
typename _ToDur,
typename _CF,
typename _CR>
210 struct __duration_cast_impl<_ToDur, _CF, _CR, true, false>
212 template<
typename _Rep,
typename _Period>
213 static constexpr _ToDur
214 __cast(
const duration<_Rep, _Period>& __d)
216 typedef typename _ToDur::rep __to_rep;
217 return _ToDur(
static_cast<__to_rep
>(
218 static_cast<_CR
>(__d.count()) /
static_cast<_CR
>(_CF::den)));
222 template<
typename _ToDur,
typename _CF,
typename _CR>
223 struct __duration_cast_impl<_ToDur, _CF, _CR, false, true>
225 template<
typename _Rep,
typename _Period>
226 static constexpr _ToDur
227 __cast(
const duration<_Rep, _Period>& __d)
229 typedef typename _ToDur::rep __to_rep;
230 return _ToDur(
static_cast<__to_rep
>(
231 static_cast<_CR
>(__d.count()) *
static_cast<_CR
>(_CF::num)));
235 template<
typename _Tp>
240 template<
typename _Rep,
typename _Period>
241 struct __is_duration<
duration<_Rep, _Period>>
245 template<
typename _Tp>
246 using __enable_if_is_duration
247 =
typename enable_if<__is_duration<_Tp>::value, _Tp>::type;
249 template<
typename _Tp>
250 using __disable_if_is_duration
251 =
typename enable_if<!__is_duration<_Tp>::value, _Tp>::type;
253#if __cplusplus >= 201703L
254 template<
typename _Tp>
255 inline constexpr bool __is_duration_v =
false;
256 template<
typename _Rep,
typename _Period>
257 inline constexpr bool __is_duration_v<duration<_Rep, _Period>> =
true;
258 template<
typename _Tp>
259 inline constexpr bool __is_time_point_v =
false;
260 template<
typename _Clock,
typename _Dur>
261 inline constexpr bool __is_time_point_v<time_point<_Clock, _Dur>> =
true;
276 template<
typename _ToDur,
typename _Rep,
typename _Period>
278 constexpr __enable_if_is_duration<_ToDur>
281#if __cpp_inline_variables && __cpp_if_constexpr
282 if constexpr (is_same_v<_ToDur, duration<_Rep, _Period>>)
287 using __to_period =
typename _ToDur::period;
288 using __to_rep =
typename _ToDur::rep;
291 using __dc = __duration_cast_impl<_ToDur, __cf, __cr,
292 __cf::num == 1, __cf::den == 1>;
293 return __dc::__cast(__d);
294#if __cpp_inline_variables && __cpp_if_constexpr
310 template<
typename _Rep>
315#if __cplusplus > 201402L
316 template <
typename _Rep>
317 inline constexpr bool treat_as_floating_point_v =
321 inline constexpr bool treat_as_floating_point_v<int> =
false;
323 inline constexpr bool treat_as_floating_point_v<long> =
false;
325 inline constexpr bool treat_as_floating_point_v<long long> =
false;
327 inline constexpr bool treat_as_floating_point_v<float> =
true;
329 inline constexpr bool treat_as_floating_point_v<double> =
true;
331 inline constexpr bool treat_as_floating_point_v<long double> =
true;
334#if __cplusplus > 201703L
335#if __cpp_lib_concepts
336 template<
typename _Tp>
337 inline constexpr bool is_clock_v =
false;
339 template<
typename _Tp>
342 typename _Tp::period;
343 typename _Tp::duration;
344 typename _Tp::time_point::clock;
345 typename _Tp::time_point::duration;
347 { _Tp::now() } -> same_as<typename _Tp::time_point>;
348 requires same_as<
typename _Tp::duration,
349 duration<typename _Tp::rep, typename _Tp::period>>;
350 requires same_as<
typename _Tp::time_point::duration,
351 typename _Tp::duration>;
353 inline constexpr bool is_clock_v<_Tp> =
true;
355 template<
typename _Tp,
typename =
void>
356 inline constexpr bool is_clock_v =
false;
358 template<
typename _Tp>
359 inline constexpr bool
360 is_clock_v<_Tp,
void_t<
typename _Tp::rep,
typename _Tp::period,
361 typename _Tp::duration,
362 typename _Tp::time_point::duration,
363 decltype(_Tp::is_steady),
364 decltype(_Tp::now())>>
365 = __and_v<is_same<
typename _Tp::duration,
367 is_same<
typename _Tp::time_point::duration,
368 typename _Tp::duration>,
369 is_same<
decltype(&_Tp::is_steady),
const bool*>,
370 is_same<
decltype(_Tp::now()),
typename _Tp::time_point>>;
373 template<
typename _Tp>
375 : bool_constant<is_clock_v<_Tp>>
379#if __cplusplus >= 201703L
390 template<
typename _ToDur,
typename _Rep,
typename _Period>
391 [[nodiscard]]
constexpr __enable_if_is_duration<_ToDur>
396 return __to - _ToDur{1};
410 template<
typename _ToDur,
typename _Rep,
typename _Period>
411 [[nodiscard]]
constexpr __enable_if_is_duration<_ToDur>
416 return __to + _ToDur{1};
431 template <
typename _ToDur,
typename _Rep,
typename _Period>
432 [[nodiscard]]
constexpr
434 __and_<__is_duration<_ToDur>,
435 __not_<treat_as_floating_point<typename _ToDur::rep>>>::value,
440 _ToDur __t1 = __t0 + _ToDur{1};
441 auto __diff0 = __d - __t0;
442 auto __diff1 = __t1 - __d;
443 if (__diff0 == __diff1)
445 if (__t0.count() & 1)
449 else if (__diff0 < __diff1)
460 template<
typename _Rep,
typename _Period>
461 [[nodiscard]]
constexpr
465 if (__d >= __d.zero())
480 template<
typename _Tp,
typename _Up>
482 __ceil_impl(
const _Tp& __t,
const _Up& __u)
484 return (__t < __u) ? (__t + _Tp{1}) : __t;
488 template<
typename _ToDur,
typename _Rep,
typename _Period>
490 ceil(
const duration<_Rep, _Period>& __d)
498 template<
typename _Rep>
501 static constexpr _Rep
505 static constexpr _Rep
509 static constexpr _Rep
514 template<
typename _Rep,
typename _Period>
520 "rep should be cv-unqualified object type");
521 static_assert(!__is_duration<_Rep>::value,
522 "rep cannot be a std::chrono::duration");
523 static_assert(__is_ratio<_Period>::value,
524 "period must be a specialization of std::ratio");
525 static_assert(_Period::num > 0,
"period must be positive");
527 template<
typename _Rep2>
530 static constexpr intmax_t
531 _S_gcd(intmax_t __m, intmax_t __n)
noexcept
535#if __cplusplus >= 201402L
538 intmax_t __rem = __m % __n;
547 return (__n == 0) ? __m : _S_gcd(__n, __m % __n);
555 template<
typename _R1,
typename _R2,
556 intmax_t __gcd1 = _S_gcd(_R1::num, _R2::num),
557 intmax_t __gcd2 = _S_gcd(_R1::den, _R2::den)>
558 using __divide =
ratio<(_R1::num / __gcd1) * (_R2::den / __gcd2),
559 (_R1::den / __gcd2) * (_R2::num / __gcd1)>;
562 template<
typename _Period2>
564 = __bool_constant<__divide<_Period2, _Period>::den == 1>;
569 using period =
typename _Period::type;
572 constexpr duration() =
default;
574 duration(
const duration&) =
default;
578 template<
typename _Rep2,
typename = _Require<
579 is_convertible<const _Rep2&, rep>,
580 __or_<__is_float<rep>, __not_<__is_float<_Rep2>>>>>
581 constexpr explicit duration(
const _Rep2& __rep)
582 : __r(
static_cast<rep
>(__rep)) { }
584 template<
typename _Rep2,
typename _Period2,
typename = _Require<
585 is_convertible<const _Rep2&, rep>,
586 __or_<__is_float<rep>,
587 __and_<__is_harmonic<_Period2>,
588 __not_<__is_float<_Rep2>>>>>>
589 constexpr duration(
const duration<_Rep2, _Period2>& __d)
592 ~duration() =
default;
593 duration& operator=(
const duration&) =
default;
602 constexpr duration<typename common_type<rep>::type, period>
604 {
return duration<typename common_type<rep>::type, period>(__r); }
606 constexpr duration<typename common_type<rep>::type, period>
608 {
return duration<typename common_type<rep>::type, period>(-__r); }
610 _GLIBCXX17_CONSTEXPR duration&
617 _GLIBCXX17_CONSTEXPR duration
619 {
return duration(__r++); }
621 _GLIBCXX17_CONSTEXPR duration&
628 _GLIBCXX17_CONSTEXPR duration
630 {
return duration(__r--); }
632 _GLIBCXX17_CONSTEXPR duration&
633 operator+=(
const duration& __d)
639 _GLIBCXX17_CONSTEXPR duration&
640 operator-=(
const duration& __d)
646 _GLIBCXX17_CONSTEXPR duration&
647 operator*=(
const rep& __rhs)
653 _GLIBCXX17_CONSTEXPR duration&
654 operator/=(
const rep& __rhs)
661 template<
typename _Rep2 = rep>
663 __enable_if_t<!treat_as_floating_point<_Rep2>::value, duration&>
664 operator%=(
const rep& __rhs)
670 template<
typename _Rep2 = rep>
672 __enable_if_t<!treat_as_floating_point<_Rep2>::value, duration&>
673 operator%=(
const duration& __d)
680 static constexpr duration
682 {
return duration(duration_values<rep>::zero()); }
684 static constexpr duration
686 {
return duration(duration_values<rep>::min()); }
688 static constexpr duration
690 {
return duration(duration_values<rep>::max()); }
700 template<
typename _Rep1,
typename _Period1,
701 typename _Rep2,
typename _Period2>
705 const duration<_Rep2, _Period2>& __rhs)
707 typedef duration<_Rep1, _Period1> __dur1;
708 typedef duration<_Rep2, _Period2> __dur2;
710 return __cd(__cd(__lhs).count() + __cd(__rhs).count());
714 template<
typename _Rep1,
typename _Period1,
715 typename _Rep2,
typename _Period2>
724 return __cd(__cd(__lhs).count() - __cd(__rhs).count());
735 template<
typename _Rep1,
typename _Rep2,
737 using __common_rep_t =
typename
747 template<
typename _Rep1,
typename _Period,
typename _Rep2>
748 constexpr duration<__common_rep_t<_Rep1, _Rep2>, _Period>
749 operator*(
const duration<_Rep1, _Period>& __d,
const _Rep2& __s)
751 typedef duration<typename common_type<_Rep1, _Rep2>::type, _Period>
753 return __cd(__cd(__d).count() * __s);
756 template<
typename _Rep1,
typename _Rep2,
typename _Period>
759 {
return __d * __s; }
761 template<
typename _Rep1,
typename _Period,
typename _Rep2>
763 duration<__common_rep_t<_Rep1, __disable_if_is_duration<_Rep2>>, _Period>
768 return __cd(__cd(__d).count() / __s);
771 template<
typename _Rep1,
typename _Period1,
772 typename _Rep2,
typename _Period2>
780 return __cd(__lhs).count() / __cd(__rhs).count();
784 template<
typename _Rep1,
typename _Period,
typename _Rep2>
786 duration<__common_rep_t<_Rep1, __disable_if_is_duration<_Rep2>>, _Period>
791 return __cd(__cd(__d).count() % __s);
794 template<
typename _Rep1,
typename _Period1,
795 typename _Rep2,
typename _Period2>
797 duration<_Rep2, _Period2>>::type
804 return __cd(__cd(__lhs).count() % __cd(__rhs).count());
815 template<
typename _Rep1,
typename _Period1,
816 typename _Rep2,
typename _Period2>
819 const duration<_Rep2, _Period2>& __rhs)
821 typedef duration<_Rep1, _Period1> __dur1;
822 typedef duration<_Rep2, _Period2> __dur2;
824 return __ct(__lhs).count() == __ct(__rhs).count();
827 template<
typename _Rep1,
typename _Period1,
828 typename _Rep2,
typename _Period2>
836 return __ct(__lhs).count() < __ct(__rhs).count();
839#if __cpp_lib_three_way_comparison
840 template<
typename _Rep1,
typename _Period1,
841 typename _Rep2,
typename _Period2>
842 requires three_way_comparable<common_type_t<_Rep1, _Rep2>>
849 return __ct(__lhs).count() <=> __ct(__rhs).count();
852 template<
typename _Rep1,
typename _Period1,
853 typename _Rep2,
typename _Period2>
855 operator!=(
const duration<_Rep1, _Period1>& __lhs,
856 const duration<_Rep2, _Period2>& __rhs)
857 {
return !(__lhs == __rhs); }
860 template<
typename _Rep1,
typename _Period1,
861 typename _Rep2,
typename _Period2>
865 {
return !(__rhs < __lhs); }
867 template<
typename _Rep1,
typename _Period1,
868 typename _Rep2,
typename _Period2>
872 {
return __rhs < __lhs; }
874 template<
typename _Rep1,
typename _Period1,
875 typename _Rep2,
typename _Period2>
879 {
return !(__lhs < __rhs); }
884#ifdef _GLIBCXX_USE_C99_STDINT
885# define _GLIBCXX_CHRONO_INT64_T int64_t
886#elif defined __INT64_TYPE__
887# define _GLIBCXX_CHRONO_INT64_T __INT64_TYPE__
890 "Representation type for nanoseconds must have at least 64 bits");
891# define _GLIBCXX_CHRONO_INT64_T long long
913#if __cplusplus > 201703L
927#undef _GLIBCXX_CHRONO_INT64_T
929 template<
typename _Clock,
typename _Dur>
932 static_assert(__is_duration<_Dur>::value,
933 "duration must be a specialization of std::chrono::duration");
936 typedef _Clock clock;
937 typedef _Dur duration;
938 typedef typename duration::rep rep;
939 typedef typename duration::period period;
941 constexpr time_point() : __d(duration::zero())
944 constexpr explicit time_point(
const duration& __dur)
949 template<
typename _Dur2,
950 typename = _Require<is_convertible<_Dur2, _Dur>>>
951 constexpr time_point(
const time_point<clock, _Dur2>& __t)
952 : __d(__t.time_since_epoch())
957 time_since_epoch()
const
960#if __cplusplus > 201703L
961 constexpr time_point&
970 {
return time_point{__d++}; }
972 constexpr time_point&
981 {
return time_point{__d--}; }
985 _GLIBCXX17_CONSTEXPR time_point&
986 operator+=(
const duration& __dur)
992 _GLIBCXX17_CONSTEXPR time_point&
993 operator-=(
const duration& __dur)
1000 static constexpr time_point
1002 {
return time_point(duration::min()); }
1004 static constexpr time_point
1006 {
return time_point(duration::max()); }
1024 template<
typename _ToDur,
typename _Clock,
typename _Dur>
1025 _GLIBCXX_NODISCARD
constexpr
1033#if __cplusplus > 201402L
1046 template<
typename _ToDur,
typename _Clock,
typename _Dur>
1047 [[nodiscard]]
constexpr
1067 template<
typename _ToDur,
typename _Clock,
typename _Dur>
1068 [[nodiscard]]
constexpr
1089 template<
typename _ToDur,
typename _Clock,
typename _Dur>
1090 [[nodiscard]]
constexpr
1092 && !treat_as_floating_point_v<typename _ToDur::rep>,
1093 time_point<_Clock, _ToDur>>
1105 template<
typename _Clock,
typename _Dur1,
1106 typename _Rep2,
typename _Period2>
1107 constexpr time_point<_Clock,
1110 const duration<_Rep2, _Period2>& __rhs)
1112 typedef duration<_Rep2, _Period2> __dur2;
1114 typedef time_point<_Clock, __ct> __time_point;
1115 return __time_point(__lhs.time_since_epoch() + __rhs);
1119 template<
typename _Rep1,
typename _Period1,
1120 typename _Clock,
typename _Dur2>
1129 return __time_point(__rhs.time_since_epoch() + __lhs);
1133 template<
typename _Clock,
typename _Dur1,
1134 typename _Rep2,
typename _Period2>
1135 constexpr time_point<_Clock,
1143 return __time_point(__lhs.time_since_epoch() -__rhs);
1147 template<
typename _Clock,
typename _Dur1,
typename _Dur2>
1151 {
return __lhs.time_since_epoch() - __rhs.time_since_epoch(); }
1159 template<
typename _Clock,
typename _Dur1,
typename _Dur2>
1161 operator==(
const time_point<_Clock, _Dur1>& __lhs,
1162 const time_point<_Clock, _Dur2>& __rhs)
1163 {
return __lhs.time_since_epoch() == __rhs.time_since_epoch(); }
1165#if __cpp_lib_three_way_comparison
1166 template<
typename _Clock,
typename _Dur1,
1167 three_way_comparable_with<_Dur1> _Dur2>
1169 operator<=>(
const time_point<_Clock, _Dur1>& __lhs,
1170 const time_point<_Clock, _Dur2>& __rhs)
1171 {
return __lhs.time_since_epoch() <=> __rhs.time_since_epoch(); }
1173 template<
typename _Clock,
typename _Dur1,
typename _Dur2>
1177 {
return !(__lhs == __rhs); }
1180 template<
typename _Clock,
typename _Dur1,
typename _Dur2>
1184 {
return __lhs.time_since_epoch() < __rhs.time_since_epoch(); }
1186 template<
typename _Clock,
typename _Dur1,
typename _Dur2>
1190 {
return !(__rhs < __lhs); }
1192 template<
typename _Clock,
typename _Dur1,
typename _Dur2>
1196 {
return __rhs < __lhs; }
1198 template<
typename _Clock,
typename _Dur1,
typename _Dur2>
1202 {
return !(__lhs < __rhs); }
1226_GLIBCXX_BEGIN_INLINE_ABI_NAMESPACE(_V2)
1237 typedef duration::rep rep;
1238 typedef duration::period period;
1241 static_assert(system_clock::duration::min()
1242 < system_clock::duration::zero(),
1243 "a clock's minimum duration cannot be less than its epoch");
1245 static constexpr bool is_steady =
false;
1251 [[__gnu__::__always_inline__]]
1253 to_time_t(
const time_point& __t)
noexcept
1256 (__t.time_since_epoch()).count());
1259 [[__gnu__::__always_inline__]]
1261 from_time_t(std::time_t __t)
noexcept
1279 typedef duration::rep rep;
1280 typedef duration::period period;
1283 static constexpr bool is_steady =
true;
1300_GLIBCXX_END_INLINE_ABI_NAMESPACE(_V2)
1302#if __cplusplus >= 202002L
1305 template<
typename _Duration>
1307 using sys_seconds = sys_time<seconds>;
1308 using sys_days = sys_time<days>;
1310 using file_clock = ::std::filesystem::__file_clock;
1312 template<
typename _Duration>
1316 template<>
struct is_clock<steady_clock> :
true_type { };
1317 template<>
struct is_clock<file_clock> : true_type { };
1319 template<>
inline constexpr bool is_clock_v<system_clock> =
true;
1320 template<>
inline constexpr bool is_clock_v<steady_clock> =
true;
1321 template<>
inline constexpr bool is_clock_v<file_clock> =
true;
1324#elif __cplusplus >= 202002L
1328 template<
typename _Duration>
1330 using sys_seconds = sys_time<seconds>;
1331 using sys_days = sys_time<days>;
1335#ifdef __glibcxx_chrono_udls
1367#pragma GCC diagnostic push
1368#pragma GCC diagnostic ignored "-Wliteral-suffix"
1370 template<
typename _Dur,
char... _Digits>
1371 constexpr _Dur __check_overflow()
1373 using _Val = __parse_int::_Parse_int<_Digits...>;
1374 constexpr typename _Dur::rep __repval = _Val::value;
1375 static_assert(__repval >= 0 && __repval == _Val::value,
1376 "literal value cannot be represented by duration type");
1377 return _Dur(__repval);
1382 constexpr chrono::duration<long double, ratio<3600,1>>
1383 operator""h(
long double __hours)
1387 template <
char... _Digits>
1394 operator""min(
long double __mins)
1398 template <
char... _Digits>
1405 operator""s(
long double __secs)
1409 template <
char... _Digits>
1416 operator""ms(
long double __msecs)
1420 template <
char... _Digits>
1427 operator""us(
long double __usecs)
1431 template <
char... _Digits>
1438 operator""ns(
long double __nsecs)
1442 template <
char... _Digits>
1447#pragma GCC diagnostic pop
1454 using namespace literals::chrono_literals;
1458#if __cplusplus >= 201703L && _GLIBCXX_HOSTED
1464 using rep = duration::rep;
1465 using period = duration::period;
1466 using time_point = chrono::time_point<__file_clock>;
1467 static constexpr bool is_steady =
false;
1471 {
return _S_from_sys(chrono::system_clock::now()); }
1473#if __cplusplus > 201703L
1474 template<
typename _Dur>
1476 chrono::file_time<common_type_t<_Dur, chrono::seconds>>
1477 from_sys(
const chrono::sys_time<_Dur>& __t)
noexcept
1478 {
return _S_from_sys(__t); }
1481 template<
typename _Dur>
1483 chrono::sys_time<common_type_t<_Dur, chrono::seconds>>
1484 to_sys(
const chrono::file_time<_Dur>& __t)
noexcept
1485 {
return _S_to_sys(__t); }
1489 using __sys_clock = chrono::system_clock;
1498 template<
typename _Dur>
1500 chrono::time_point<__file_clock, common_type_t<_Dur, chrono::seconds>>
1501 _S_from_sys(
const chrono::time_point<__sys_clock, _Dur>& __t)
noexcept
1504 using __file_time = chrono::time_point<__file_clock, _CDur>;
1505 return __file_time{__t.time_since_epoch()} - _S_epoch_diff;
1509 template<
typename _Dur>
1511 chrono::time_point<__sys_clock, common_type_t<_Dur, chrono::seconds>>
1512 _S_to_sys(
const chrono::time_point<__file_clock, _Dur>& __t)
noexcept
1515 using __sys_time = chrono::time_point<__sys_clock, _CDur>;
1516 return __sys_time{__t.time_since_epoch()} + _S_epoch_diff;
1523#if ! defined _GLIBCXX_NO_SLEEP || defined _GLIBCXX_HAS_GTHREADS \
1524 || _GLIBCXX_HAVE_LINUX_FUTEX
1529#pragma GCC diagnostic push
1530#pragma GCC diagnostic ignored "-Wc++17-extensions"
1533 template<
typename _Rep,
typename _Period>
1534 [[__nodiscard__]] _GLIBCXX14_CONSTEXPR
inline
1538 struct ::timespec __ts{};
1540 if (__d < __d.zero())
1543 if constexpr (ratio_greater<_Period, ratio<1>>::value
1549 chrono::duration<double> __fmax(chrono::seconds::max());
1550 if (__d > __fmax) [[__unlikely__]]
1551 return chrono::__to_timeout_timespec(chrono::seconds::max());
1556 if constexpr (is_integral<time_t>::value)
1560 if (__s.count() > __tmax) [[__unlikely__]]
1562 __ts.tv_sec = __tmax;
1570 if (__ns.count() > 999999999) [[__unlikely__]]
1573 __ts.tv_sec =
static_cast<time_t
>(__s.count());
1574 __ts.tv_nsec =
static_cast<long>(__ns.count());
1577#pragma GCC diagnostic pop
1583 template<
typename _Clock,
typename _Dur>
1584 [[__nodiscard__]] _GLIBCXX14_CONSTEXPR
inline
1588 return chrono::__to_timeout_timespec(__t.time_since_epoch());
1596_GLIBCXX_END_NAMESPACE_VERSION
constexpr __enable_if_is_duration< _ToDur > ceil(const duration< _Rep, _Period > &__d)
constexpr bool operator==(const duration< _Rep1, _Period1 > &__lhs, const duration< _Rep2, _Period2 > &__rhs)
duration< int64_t, ratio< 604800 > > weeks
weeks
constexpr __enable_if_is_duration< _ToDur > floor(const duration< _Rep, _Period > &__d)
duration< int64_t, ratio< 2629746 > > months
months
constexpr enable_if_t< __and_< __is_duration< _ToDur >, __not_< treat_as_floating_point< typename _ToDur::rep > > >::value, _ToDur > round(const duration< _Rep, _Period > &__d)
duration< int64_t, ratio< 86400 > > days
days
duration< int64_t, ratio< 31556952 > > years
years
constexpr bool operator<=(const duration< _Rep1, _Period1 > &__lhs, const duration< _Rep2, _Period2 > &__rhs)
duration< int64_t, ratio< 3600 > > hours
hours
constexpr bool operator>=(const duration< _Rep1, _Period1 > &__lhs, const duration< _Rep2, _Period2 > &__rhs)
system_clock high_resolution_clock
Highest-resolution clock.
constexpr duration< __common_rep_t< _Rep2, _Rep1 >, _Period > operator*(const _Rep1 &__s, const duration< _Rep2, _Period > &__d)
duration< int64_t, nano > nanoseconds
nanoseconds
constexpr enable_if_t< numeric_limits< _Rep >::is_signed, duration< _Rep, _Period > > abs(duration< _Rep, _Period > __d)
constexpr duration< __common_rep_t< _Rep1, __disable_if_is_duration< _Rep2 > >, _Period > operator%(const duration< _Rep1, _Period > &__d, const _Rep2 &__s)
constexpr time_point< local_t, typename common_type< _Dur1, duration< _Rep2, _Period2 > >::type > operator+(const time_point< local_t, _Dur1 > &__lhs, const duration< _Rep2, _Period2 > &__rhs)
duration< int64_t, ratio< 60 > > minutes
minutes
constexpr __enable_if_t< __is_duration< _ToDur >::value, time_point< _Clock, _ToDur > > time_point_cast(const time_point< _Clock, _Dur > &__t)
duration< int64_t, milli > milliseconds
milliseconds
duration< int64_t, micro > microseconds
microseconds
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.
constexpr auto operator<=>(const duration< _Rep1, _Period1 > &__lhs, const duration< _Rep2, _Period2 > &__rhs)
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.
constexpr bool operator<(const duration< _Rep1, _Period1 > &__lhs, const duration< _Rep2, _Period2 > &__rhs)
duration< int64_t > seconds
seconds
constexpr bool operator>(const duration< _Rep1, _Period1 > &__lhs, const duration< _Rep2, _Period2 > &__rhs)
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.
constexpr duration< __common_rep_t< _Rep1, __disable_if_is_duration< _Rep2 > >, _Period > operator/(const duration< _Rep1, _Period > &__d, const _Rep2 &__s)
constexpr duration< __common_rep_t< _Rep1, _Rep2 >, _Period > operator*(const duration< _Rep1, _Period > &__d, const _Rep2 &__s)
constexpr __enable_if_is_duration< _ToDur > ceil(const duration< _Rep, _Period > &__d)
constexpr __enable_if_is_duration< _ToDur > duration_cast(const duration< _Rep, _Period > &__d)
typename __ratio_divide< _R1, _R2 >::type ratio_divide
ratio_divide
__bool_constant< true > true_type
The type used as a compile-time boolean with true value.
typename common_type< _Tp... >::type common_type_t
Alias template for common_type.
typename enable_if< _Cond, _Tp >::type enable_if_t
Alias template for enable_if.
__bool_constant< false > false_type
The type used as a compile-time boolean with false value.
constexpr const _Tp & min(const _Tp &, const _Tp &)
This does what you think it does.
void void_t
A metafunction that always yields void, used for detecting valid types.
ISO C++ entities toplevel namespace is std.
ISO C++ inline namespace for literal suffixes.
Implementation details not part of the namespace std interface.
ISO C++ 2011 namespace for date and time utilities.
ISO C++ 2017 namespace for File System library.
static constexpr int digits
static constexpr _Tp max() noexcept
static constexpr _Tp lowest() noexcept
Provides compile-time rational arithmetic.
Define a member typedef type only if a boolean constant is true.
chrono::duration represents a distance between two points in time
chrono::time_point represents a point in time as measured by a clock
[concept.same], concept same_as