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#ifdef __glibcxx_chrono_cxx20
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>>
381#if __cplusplus >= 201703L
392 template<
typename _ToDur,
typename _Rep,
typename _Period>
393 [[nodiscard]]
constexpr __enable_if_is_duration<_ToDur>
398 return __to - _ToDur{1};
412 template<
typename _ToDur,
typename _Rep,
typename _Period>
413 [[nodiscard]]
constexpr __enable_if_is_duration<_ToDur>
418 return __to + _ToDur{1};
433 template <
typename _ToDur,
typename _Rep,
typename _Period>
434 [[nodiscard]]
constexpr
436 __and_<__is_duration<_ToDur>,
437 __not_<treat_as_floating_point<typename _ToDur::rep>>>::value,
442 _ToDur __t1 = __t0 + _ToDur{1};
443 auto __diff0 = __d - __t0;
444 auto __diff1 = __t1 - __d;
445 if (__diff0 == __diff1)
447 if (__t0.count() & 1)
451 else if (__diff0 < __diff1)
462 template<
typename _Rep,
typename _Period>
463 [[nodiscard]]
constexpr
467 if (__d >= __d.zero())
482 template<
typename _Tp,
typename _Up>
484 __ceil_impl(
const _Tp& __t,
const _Up& __u)
486 return (__t < __u) ? (__t + _Tp{1}) : __t;
490 template<
typename _ToDur,
typename _Rep,
typename _Period>
492 ceil(
const duration<_Rep, _Period>& __d)
500 template<
typename _Rep>
503 static constexpr _Rep
507 static constexpr _Rep
511 static constexpr _Rep
516 template<
typename _Rep,
typename _Period>
522 "rep should be cv-unqualified object type");
523 static_assert(!__is_duration<_Rep>::value,
524 "rep cannot be a std::chrono::duration");
525 static_assert(__is_ratio<_Period>::value,
526 "period must be a specialization of std::ratio");
527 static_assert(_Period::num > 0,
"period must be positive");
529 template<
typename _Rep2>
532 static constexpr intmax_t
533 _S_gcd(intmax_t __m, intmax_t __n)
noexcept
537#if __cpp_constexpr >= 201304L
540 intmax_t __rem = __m % __n;
549 return (__n == 0) ? __m : _S_gcd(__n, __m % __n);
557 template<
typename _R1,
typename _R2,
558 intmax_t __gcd1 = _S_gcd(_R1::num, _R2::num),
559 intmax_t __gcd2 = _S_gcd(_R1::den, _R2::den)>
560 using __divide =
ratio<(_R1::num / __gcd1) * (_R2::den / __gcd2),
561 (_R1::den / __gcd2) * (_R2::num / __gcd1)>;
564 template<
typename _Period2>
566 = __bool_constant<__divide<_Period2, _Period>::den == 1>;
571 using period =
typename _Period::type;
574 constexpr duration() =
default;
576 duration(
const duration&) =
default;
580 template<
typename _Rep2,
typename = _Require<
581 is_convertible<const _Rep2&, rep>,
582 __or_<__is_float<rep>, __not_<__is_float<_Rep2>>>>>
583 constexpr explicit duration(
const _Rep2& __rep)
584 : __r(
static_cast<rep
>(__rep)) { }
586 template<
typename _Rep2,
typename _Period2,
typename = _Require<
587 is_convertible<const _Rep2&, rep>,
588 __or_<__is_float<rep>,
589 __and_<__is_harmonic<_Period2>,
590 __not_<__is_float<_Rep2>>>>>>
591 constexpr duration(
const duration<_Rep2, _Period2>& __d)
594 ~duration() =
default;
595 duration& operator=(
const duration&) =
default;
604 constexpr duration<typename common_type<rep>::type, period>
606 {
return duration<typename common_type<rep>::type, period>(__r); }
608 constexpr duration<typename common_type<rep>::type, period>
610 {
return duration<typename common_type<rep>::type, period>(-__r); }
612 _GLIBCXX17_CONSTEXPR duration&
619 _GLIBCXX17_CONSTEXPR duration
621 {
return duration(__r++); }
623 _GLIBCXX17_CONSTEXPR duration&
630 _GLIBCXX17_CONSTEXPR duration
632 {
return duration(__r--); }
634 _GLIBCXX17_CONSTEXPR duration&
635 operator+=(
const duration& __d)
641 _GLIBCXX17_CONSTEXPR duration&
642 operator-=(
const duration& __d)
648 _GLIBCXX17_CONSTEXPR duration&
649 operator*=(
const rep& __rhs)
655 _GLIBCXX17_CONSTEXPR duration&
656 operator/=(
const rep& __rhs)
663 template<
typename _Rep2 = rep>
665 __enable_if_t<!treat_as_floating_point<_Rep2>::value, duration&>
666 operator%=(
const rep& __rhs)
672 template<
typename _Rep2 = rep>
674 __enable_if_t<!treat_as_floating_point<_Rep2>::value, duration&>
675 operator%=(
const duration& __d)
682 static constexpr duration
684 {
return duration(duration_values<rep>::zero()); }
686 static constexpr duration
688 {
return duration(duration_values<rep>::min()); }
690 static constexpr duration
692 {
return duration(duration_values<rep>::max()); }
702 template<
typename _Rep1,
typename _Period1,
703 typename _Rep2,
typename _Period2>
707 const duration<_Rep2, _Period2>& __rhs)
709 typedef duration<_Rep1, _Period1> __dur1;
710 typedef duration<_Rep2, _Period2> __dur2;
712 return __cd(__cd(__lhs).count() + __cd(__rhs).count());
716 template<
typename _Rep1,
typename _Period1,
717 typename _Rep2,
typename _Period2>
726 return __cd(__cd(__lhs).count() - __cd(__rhs).count());
737 template<
typename _Rep1,
typename _Rep2,
739 using __common_rep_t =
typename
749 template<
typename _Rep1,
typename _Period,
typename _Rep2>
750 constexpr duration<__common_rep_t<_Rep1, _Rep2>, _Period>
751 operator*(
const duration<_Rep1, _Period>& __d,
const _Rep2& __s)
753 typedef duration<typename common_type<_Rep1, _Rep2>::type, _Period>
755 return __cd(__cd(__d).count() * __s);
758 template<
typename _Rep1,
typename _Rep2,
typename _Period>
761 {
return __d * __s; }
763 template<
typename _Rep1,
typename _Period,
typename _Rep2>
765 duration<__common_rep_t<_Rep1, __disable_if_is_duration<_Rep2>>, _Period>
770 return __cd(__cd(__d).count() / __s);
773 template<
typename _Rep1,
typename _Period1,
774 typename _Rep2,
typename _Period2>
782 return __cd(__lhs).count() / __cd(__rhs).count();
786 template<
typename _Rep1,
typename _Period,
typename _Rep2>
788 duration<__common_rep_t<_Rep1, __disable_if_is_duration<_Rep2>>, _Period>
793 return __cd(__cd(__d).count() % __s);
796 template<
typename _Rep1,
typename _Period1,
797 typename _Rep2,
typename _Period2>
799 duration<_Rep2, _Period2>>::type
806 return __cd(__cd(__lhs).count() % __cd(__rhs).count());
817 template<
typename _Rep1,
typename _Period1,
818 typename _Rep2,
typename _Period2>
821 const duration<_Rep2, _Period2>& __rhs)
823 typedef duration<_Rep1, _Period1> __dur1;
824 typedef duration<_Rep2, _Period2> __dur2;
826 return __ct(__lhs).count() == __ct(__rhs).count();
829 template<
typename _Rep1,
typename _Period1,
830 typename _Rep2,
typename _Period2>
838 return __ct(__lhs).count() < __ct(__rhs).count();
841#if __cpp_lib_three_way_comparison
842 template<
typename _Rep1,
typename _Period1,
843 typename _Rep2,
typename _Period2>
844 requires three_way_comparable<common_type_t<_Rep1, _Rep2>>
851 return __ct(__lhs).count() <=> __ct(__rhs).count();
854 template<
typename _Rep1,
typename _Period1,
855 typename _Rep2,
typename _Period2>
857 operator!=(
const duration<_Rep1, _Period1>& __lhs,
858 const duration<_Rep2, _Period2>& __rhs)
859 {
return !(__lhs == __rhs); }
862 template<
typename _Rep1,
typename _Period1,
863 typename _Rep2,
typename _Period2>
867 {
return !(__rhs < __lhs); }
869 template<
typename _Rep1,
typename _Period1,
870 typename _Rep2,
typename _Period2>
874 {
return __rhs < __lhs; }
876 template<
typename _Rep1,
typename _Period1,
877 typename _Rep2,
typename _Period2>
881 {
return !(__lhs < __rhs); }
886#ifdef _GLIBCXX_USE_C99_STDINT
887# define _GLIBCXX_CHRONO_INT64_T int64_t
888#elif defined __INT64_TYPE__
889# define _GLIBCXX_CHRONO_INT64_T __INT64_TYPE__
892 "Representation type for nanoseconds must have at least 64 bits");
893# define _GLIBCXX_CHRONO_INT64_T long long
915#ifdef __glibcxx_chrono_cxx20
917 using days = duration<_GLIBCXX_CHRONO_INT64_T, ratio<86400>>;
929#undef _GLIBCXX_CHRONO_INT64_T
931 template<
typename _Clock,
typename _Dur>
934 static_assert(__is_duration<_Dur>::value,
935 "duration must be a specialization of std::chrono::duration");
938 typedef _Clock clock;
939 typedef _Dur duration;
940 typedef typename duration::rep rep;
941 typedef typename duration::period period;
943 constexpr time_point() : __d(duration::zero())
946 constexpr explicit time_point(
const duration& __dur)
951 template<
typename _Dur2,
952 typename = _Require<is_convertible<_Dur2, _Dur>>>
953 constexpr time_point(
const time_point<clock, _Dur2>& __t)
954 : __d(__t.time_since_epoch())
959 time_since_epoch()
const
962#ifdef __glibcxx_chrono_cxx20
963 constexpr time_point&
972 {
return time_point{__d++}; }
974 constexpr time_point&
983 {
return time_point{__d--}; }
987 _GLIBCXX17_CONSTEXPR time_point&
988 operator+=(
const duration& __dur)
994 _GLIBCXX17_CONSTEXPR time_point&
995 operator-=(
const duration& __dur)
1002 static constexpr time_point
1004 {
return time_point(duration::min()); }
1006 static constexpr time_point
1008 {
return time_point(duration::max()); }
1026 template<
typename _ToDur,
typename _Clock,
typename _Dur>
1027 _GLIBCXX_NODISCARD
constexpr
1037#if __cplusplus >= 201703L
1050 template<
typename _ToDur,
typename _Clock,
typename _Dur>
1051 [[nodiscard]]
constexpr
1071 template<
typename _ToDur,
typename _Clock,
typename _Dur>
1072 [[nodiscard]]
constexpr
1093 template<
typename _ToDur,
typename _Clock,
typename _Dur>
1094 [[nodiscard]]
constexpr
1096 && !treat_as_floating_point_v<typename _ToDur::rep>,
1097 time_point<_Clock, _ToDur>>
1109 template<
typename _Clock,
typename _Dur1,
1110 typename _Rep2,
typename _Period2>
1111 constexpr time_point<_Clock,
1114 const duration<_Rep2, _Period2>& __rhs)
1116 typedef duration<_Rep2, _Period2> __dur2;
1118 typedef time_point<_Clock, __ct> __time_point;
1119 return __time_point(__lhs.time_since_epoch() + __rhs);
1123 template<
typename _Rep1,
typename _Period1,
1124 typename _Clock,
typename _Dur2>
1133 return __time_point(__rhs.time_since_epoch() + __lhs);
1137 template<
typename _Clock,
typename _Dur1,
1138 typename _Rep2,
typename _Period2>
1139 constexpr time_point<_Clock,
1147 return __time_point(__lhs.time_since_epoch() -__rhs);
1151 template<
typename _Clock,
typename _Dur1,
typename _Dur2>
1155 {
return __lhs.time_since_epoch() - __rhs.time_since_epoch(); }
1163 template<
typename _Clock,
typename _Dur1,
typename _Dur2>
1165 operator==(
const time_point<_Clock, _Dur1>& __lhs,
1166 const time_point<_Clock, _Dur2>& __rhs)
1167 {
return __lhs.time_since_epoch() == __rhs.time_since_epoch(); }
1169#if __cpp_lib_three_way_comparison
1170 template<
typename _Clock,
typename _Dur1,
1171 three_way_comparable_with<_Dur1> _Dur2>
1173 operator<=>(
const time_point<_Clock, _Dur1>& __lhs,
1174 const time_point<_Clock, _Dur2>& __rhs)
1175 {
return __lhs.time_since_epoch() <=> __rhs.time_since_epoch(); }
1177 template<
typename _Clock,
typename _Dur1,
typename _Dur2>
1181 {
return !(__lhs == __rhs); }
1184 template<
typename _Clock,
typename _Dur1,
typename _Dur2>
1188 {
return __lhs.time_since_epoch() < __rhs.time_since_epoch(); }
1190 template<
typename _Clock,
typename _Dur1,
typename _Dur2>
1194 {
return !(__rhs < __lhs); }
1196 template<
typename _Clock,
typename _Dur1,
typename _Dur2>
1200 {
return __rhs < __lhs; }
1202 template<
typename _Clock,
typename _Dur1,
typename _Dur2>
1206 {
return !(__lhs < __rhs); }
1230_GLIBCXX_BEGIN_INLINE_ABI_NAMESPACE(_V2)
1241 typedef duration::rep rep;
1242 typedef duration::period period;
1245 static_assert(system_clock::duration::min()
1246 < system_clock::duration::zero(),
1247 "a clock's minimum duration cannot be less than its epoch");
1249 static constexpr bool is_steady =
false;
1255 [[__gnu__::__always_inline__]]
1257 to_time_t(
const time_point& __t)
noexcept
1260 (__t.time_since_epoch()).count());
1263 [[__gnu__::__always_inline__]]
1265 from_time_t(std::time_t __t)
noexcept
1283 typedef duration::rep rep;
1284 typedef duration::period period;
1287 static constexpr bool is_steady =
true;
1304_GLIBCXX_END_INLINE_ABI_NAMESPACE(_V2)
1306#ifdef __glibcxx_chrono_cxx20
1309 template<typename _Duration>
1311 using sys_seconds = sys_time<seconds>;
1312 using sys_days = sys_time<days>;
1314 using file_clock = ::std::filesystem::__file_clock;
1316 template<
typename _Duration>
1320 template<>
struct is_clock<steady_clock> :
true_type { };
1321 template<>
struct is_clock<file_clock> : true_type { };
1323 template<>
inline constexpr bool is_clock_v<system_clock> =
true;
1324 template<>
inline constexpr bool is_clock_v<steady_clock> =
true;
1325 template<>
inline constexpr bool is_clock_v<file_clock> =
true;
1328#elif defined __glibcxx_chrono_cxx20
1332 template<
typename _Duration>
1334 using sys_seconds = sys_time<seconds>;
1335 using sys_days = sys_time<days>;
1339#ifdef __glibcxx_chrono_udls
1371#pragma GCC diagnostic push
1372#pragma GCC diagnostic ignored "-Wliteral-suffix"
1374 template<
typename _Dur,
char... _Digits>
1375 constexpr _Dur __check_overflow()
1377 using _Val = __parse_int::_Parse_int<_Digits...>;
1378 constexpr typename _Dur::rep __repval = _Val::value;
1379 static_assert(__repval >= 0 && __repval == _Val::value,
1380 "literal value cannot be represented by duration type");
1381 return _Dur(__repval);
1386 constexpr chrono::duration<long double, ratio<3600,1>>
1387 operator""h(
long double __hours)
1391 template <
char... _Digits>
1398 operator""min(
long double __mins)
1402 template <
char... _Digits>
1409 operator""s(
long double __secs)
1413 template <
char... _Digits>
1420 operator""ms(
long double __msecs)
1424 template <
char... _Digits>
1431 operator""us(
long double __usecs)
1435 template <
char... _Digits>
1442 operator""ns(
long double __nsecs)
1446 template <
char... _Digits>
1451#pragma GCC diagnostic pop
1458 using namespace literals::chrono_literals;
1462#if __cplusplus >= 201703L && _GLIBCXX_HOSTED
1468 using rep = duration::rep;
1469 using period = duration::period;
1470 using time_point = chrono::time_point<__file_clock>;
1471 static constexpr bool is_steady =
false;
1475 {
return _S_from_sys(chrono::system_clock::now()); }
1477#if __cplusplus > 201703L
1478 template<
typename _Dur>
1480 chrono::file_time<common_type_t<_Dur, chrono::seconds>>
1481 from_sys(
const chrono::sys_time<_Dur>& __t)
noexcept
1482 {
return _S_from_sys(__t); }
1485 template<
typename _Dur>
1487 chrono::sys_time<common_type_t<_Dur, chrono::seconds>>
1488 to_sys(
const chrono::file_time<_Dur>& __t)
noexcept
1489 {
return _S_to_sys(__t); }
1493 using __sys_clock = chrono::system_clock;
1502 template<
typename _Dur>
1504 chrono::time_point<__file_clock, common_type_t<_Dur, chrono::seconds>>
1505 _S_from_sys(
const chrono::time_point<__sys_clock, _Dur>& __t)
noexcept
1508 using __file_time = chrono::time_point<__file_clock, _CDur>;
1509 return __file_time{__t.time_since_epoch()} - _S_epoch_diff;
1513 template<
typename _Dur>
1515 chrono::time_point<__sys_clock, common_type_t<_Dur, chrono::seconds>>
1516 _S_to_sys(
const chrono::time_point<__file_clock, _Dur>& __t)
noexcept
1519 using __sys_time = chrono::time_point<__sys_clock, _CDur>;
1520 return __sys_time{__t.time_since_epoch()} + _S_epoch_diff;
1527#if ! defined _GLIBCXX_NO_SLEEP || defined _GLIBCXX_HAS_GTHREADS \
1528 || _GLIBCXX_HAVE_LINUX_FUTEX
1533#pragma GCC diagnostic push
1534#pragma GCC diagnostic ignored "-Wc++17-extensions"
1537 template<
typename _Rep,
typename _Period>
1538 [[__nodiscard__]] _GLIBCXX14_CONSTEXPR
inline
1542 struct ::timespec __ts{};
1544 if (__d < __d.zero())
1547 if constexpr (ratio_greater<_Period, ratio<1>>::value
1553 chrono::duration<double> __fmax(chrono::seconds::max());
1554 if (__d > __fmax) [[__unlikely__]]
1555 return chrono::__to_timeout_timespec(chrono::seconds::max());
1560 if constexpr (is_integral<time_t>::value)
1564 if (__s.count() > __tmax) [[__unlikely__]]
1566 __ts.tv_sec = __tmax;
1574 if (__ns.count() > 999999999) [[__unlikely__]]
1577 __ts.tv_sec =
static_cast<time_t
>(__s.count());
1578 __ts.tv_nsec =
static_cast<long>(__ns.count());
1581#pragma GCC diagnostic pop
1587 template<
typename _Clock,
typename _Dur>
1588 [[__nodiscard__]] _GLIBCXX14_CONSTEXPR
inline
1592 return chrono::__to_timeout_timespec(__t.time_since_epoch());
1600_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< 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