Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-03 08:13:14

0001 // -*- C++ -*-
0002 //===----------------------------------------------------------------------===//
0003 //
0004 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0005 // See https://llvm.org/LICENSE.txt for license information.
0006 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0007 //
0008 //===----------------------------------------------------------------------===//
0009 
0010 #ifndef _LIBCPP___CHRONO_DURATION_H
0011 #define _LIBCPP___CHRONO_DURATION_H
0012 
0013 #include <__compare/ordering.h>
0014 #include <__compare/three_way_comparable.h>
0015 #include <__config>
0016 #include <__type_traits/common_type.h>
0017 #include <__type_traits/enable_if.h>
0018 #include <__type_traits/is_convertible.h>
0019 #include <__type_traits/is_floating_point.h>
0020 #include <limits>
0021 #include <ratio>
0022 
0023 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0024 #  pragma GCC system_header
0025 #endif
0026 
0027 _LIBCPP_PUSH_MACROS
0028 #include <__undef_macros>
0029 
0030 _LIBCPP_BEGIN_NAMESPACE_STD
0031 
0032 namespace chrono {
0033 
0034 template <class _Rep, class _Period = ratio<1> >
0035 class _LIBCPP_TEMPLATE_VIS duration;
0036 
0037 template <class _Tp>
0038 inline const bool __is_duration_v = false;
0039 
0040 template <class _Rep, class _Period>
0041 inline const bool __is_duration_v<duration<_Rep, _Period> > = true;
0042 
0043 template <class _Rep, class _Period>
0044 inline const bool __is_duration_v<const duration<_Rep, _Period> > = true;
0045 
0046 template <class _Rep, class _Period>
0047 inline const bool __is_duration_v<volatile duration<_Rep, _Period> > = true;
0048 
0049 template <class _Rep, class _Period>
0050 inline const bool __is_duration_v<const volatile duration<_Rep, _Period> > = true;
0051 
0052 } // namespace chrono
0053 
0054 template <class _Rep1, class _Period1, class _Rep2, class _Period2>
0055 struct _LIBCPP_TEMPLATE_VIS common_type<chrono::duration<_Rep1, _Period1>, chrono::duration<_Rep2, _Period2> > {
0056   typedef chrono::duration<typename common_type<_Rep1, _Rep2>::type, __ratio_gcd<_Period1, _Period2> > type;
0057 };
0058 
0059 namespace chrono {
0060 
0061 // duration_cast
0062 
0063 template <class _FromDuration,
0064           class _ToDuration,
0065           class _Period = typename ratio_divide<typename _FromDuration::period, typename _ToDuration::period>::type,
0066           bool          = _Period::num == 1,
0067           bool          = _Period::den == 1>
0068 struct __duration_cast;
0069 
0070 template <class _FromDuration, class _ToDuration, class _Period>
0071 struct __duration_cast<_FromDuration, _ToDuration, _Period, true, true> {
0072   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _ToDuration operator()(const _FromDuration& __fd) const {
0073     return _ToDuration(static_cast<typename _ToDuration::rep>(__fd.count()));
0074   }
0075 };
0076 
0077 template <class _FromDuration, class _ToDuration, class _Period>
0078 struct __duration_cast<_FromDuration, _ToDuration, _Period, true, false> {
0079   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _ToDuration operator()(const _FromDuration& __fd) const {
0080     typedef typename common_type<typename _ToDuration::rep, typename _FromDuration::rep, intmax_t>::type _Ct;
0081     return _ToDuration(
0082         static_cast<typename _ToDuration::rep>(static_cast<_Ct>(__fd.count()) / static_cast<_Ct>(_Period::den)));
0083   }
0084 };
0085 
0086 template <class _FromDuration, class _ToDuration, class _Period>
0087 struct __duration_cast<_FromDuration, _ToDuration, _Period, false, true> {
0088   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _ToDuration operator()(const _FromDuration& __fd) const {
0089     typedef typename common_type<typename _ToDuration::rep, typename _FromDuration::rep, intmax_t>::type _Ct;
0090     return _ToDuration(
0091         static_cast<typename _ToDuration::rep>(static_cast<_Ct>(__fd.count()) * static_cast<_Ct>(_Period::num)));
0092   }
0093 };
0094 
0095 template <class _FromDuration, class _ToDuration, class _Period>
0096 struct __duration_cast<_FromDuration, _ToDuration, _Period, false, false> {
0097   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _ToDuration operator()(const _FromDuration& __fd) const {
0098     typedef typename common_type<typename _ToDuration::rep, typename _FromDuration::rep, intmax_t>::type _Ct;
0099     return _ToDuration(static_cast<typename _ToDuration::rep>(
0100         static_cast<_Ct>(__fd.count()) * static_cast<_Ct>(_Period::num) / static_cast<_Ct>(_Period::den)));
0101   }
0102 };
0103 
0104 template <class _ToDuration, class _Rep, class _Period, __enable_if_t<__is_duration_v<_ToDuration>, int> = 0>
0105 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _ToDuration duration_cast(const duration<_Rep, _Period>& __fd) {
0106   return __duration_cast<duration<_Rep, _Period>, _ToDuration>()(__fd);
0107 }
0108 
0109 template <class _Rep>
0110 struct _LIBCPP_TEMPLATE_VIS treat_as_floating_point : is_floating_point<_Rep> {};
0111 
0112 #if _LIBCPP_STD_VER >= 17
0113 template <class _Rep>
0114 inline constexpr bool treat_as_floating_point_v = treat_as_floating_point<_Rep>::value;
0115 #endif
0116 
0117 template <class _Rep>
0118 struct _LIBCPP_TEMPLATE_VIS duration_values {
0119 public:
0120   _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR _Rep zero() _NOEXCEPT { return _Rep(0); }
0121   _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR _Rep max() _NOEXCEPT { return numeric_limits<_Rep>::max(); }
0122   _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR _Rep min() _NOEXCEPT { return numeric_limits<_Rep>::lowest(); }
0123 };
0124 
0125 #if _LIBCPP_STD_VER >= 17
0126 template <class _ToDuration, class _Rep, class _Period, enable_if_t<__is_duration_v<_ToDuration>, int> = 0>
0127 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _ToDuration floor(const duration<_Rep, _Period>& __d) {
0128   _ToDuration __t = chrono::duration_cast<_ToDuration>(__d);
0129   if (__t > __d)
0130     __t = __t - _ToDuration{1};
0131   return __t;
0132 }
0133 
0134 template <class _ToDuration, class _Rep, class _Period, enable_if_t<__is_duration_v<_ToDuration>, int> = 0>
0135 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _ToDuration ceil(const duration<_Rep, _Period>& __d) {
0136   _ToDuration __t = chrono::duration_cast<_ToDuration>(__d);
0137   if (__t < __d)
0138     __t = __t + _ToDuration{1};
0139   return __t;
0140 }
0141 
0142 template <class _ToDuration, class _Rep, class _Period, enable_if_t<__is_duration_v<_ToDuration>, int> = 0>
0143 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _ToDuration round(const duration<_Rep, _Period>& __d) {
0144   _ToDuration __lower = chrono::floor<_ToDuration>(__d);
0145   _ToDuration __upper = __lower + _ToDuration{1};
0146   auto __lower_diff   = __d - __lower;
0147   auto __upper_diff   = __upper - __d;
0148   if (__lower_diff < __upper_diff)
0149     return __lower;
0150   if (__lower_diff > __upper_diff)
0151     return __upper;
0152   return __lower.count() & 1 ? __upper : __lower;
0153 }
0154 #endif
0155 
0156 // duration
0157 
0158 template <class _Rep, class _Period>
0159 class _LIBCPP_TEMPLATE_VIS duration {
0160   static_assert(!__is_duration_v<_Rep>, "A duration representation can not be a duration");
0161   static_assert(__is_ratio_v<_Period>, "Second template parameter of duration must be a std::ratio");
0162   static_assert(_Period::num > 0, "duration period must be positive");
0163 
0164   template <class _R1, class _R2>
0165   struct __no_overflow {
0166   private:
0167     static const intmax_t __gcd_n1_n2 = __static_gcd<_R1::num, _R2::num>;
0168     static const intmax_t __gcd_d1_d2 = __static_gcd<_R1::den, _R2::den>;
0169     static const intmax_t __n1        = _R1::num / __gcd_n1_n2;
0170     static const intmax_t __d1        = _R1::den / __gcd_d1_d2;
0171     static const intmax_t __n2        = _R2::num / __gcd_n1_n2;
0172     static const intmax_t __d2        = _R2::den / __gcd_d1_d2;
0173     static const intmax_t max         = -((intmax_t(1) << (sizeof(intmax_t) * CHAR_BIT - 1)) + 1);
0174 
0175     template <intmax_t _Xp, intmax_t _Yp, bool __overflow>
0176     struct __mul // __overflow == false
0177     {
0178       static const intmax_t value = _Xp * _Yp;
0179     };
0180 
0181     template <intmax_t _Xp, intmax_t _Yp>
0182     struct __mul<_Xp, _Yp, true> {
0183       static const intmax_t value = 1;
0184     };
0185 
0186   public:
0187     static const bool value = (__n1 <= max / __d2) && (__n2 <= max / __d1);
0188     typedef ratio<__mul<__n1, __d2, !value>::value, __mul<__n2, __d1, !value>::value> type;
0189   };
0190 
0191 public:
0192   typedef _Rep rep;
0193   typedef typename _Period::type period;
0194 
0195 private:
0196   rep __rep_;
0197 
0198 public:
0199 #ifndef _LIBCPP_CXX03_LANG
0200   constexpr duration() = default;
0201 #else
0202   _LIBCPP_HIDE_FROM_ABI duration() {}
0203 #endif
0204 
0205   template <class _Rep2,
0206             __enable_if_t<is_convertible<const _Rep2&, rep>::value &&
0207                               (treat_as_floating_point<rep>::value || !treat_as_floating_point<_Rep2>::value),
0208                           int> = 0>
0209   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit duration(const _Rep2& __r) : __rep_(__r) {}
0210 
0211   // conversions
0212   template <class _Rep2,
0213             class _Period2,
0214             __enable_if_t<__no_overflow<_Period2, period>::value && (treat_as_floating_point<rep>::value ||
0215                                                                      (__no_overflow<_Period2, period>::type::den == 1 &&
0216                                                                       !treat_as_floating_point<_Rep2>::value)),
0217                           int> = 0>
0218   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR duration(const duration<_Rep2, _Period2>& __d)
0219       : __rep_(chrono::duration_cast<duration>(__d).count()) {}
0220 
0221   // observer
0222 
0223   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR rep count() const { return __rep_; }
0224 
0225   // arithmetic
0226 
0227   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR typename common_type<duration>::type operator+() const {
0228     return typename common_type<duration>::type(*this);
0229   }
0230   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR typename common_type<duration>::type operator-() const {
0231     return typename common_type<duration>::type(-__rep_);
0232   }
0233   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 duration& operator++() {
0234     ++__rep_;
0235     return *this;
0236   }
0237   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 duration operator++(int) { return duration(__rep_++); }
0238   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 duration& operator--() {
0239     --__rep_;
0240     return *this;
0241   }
0242   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 duration operator--(int) { return duration(__rep_--); }
0243 
0244   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 duration& operator+=(const duration& __d) {
0245     __rep_ += __d.count();
0246     return *this;
0247   }
0248   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 duration& operator-=(const duration& __d) {
0249     __rep_ -= __d.count();
0250     return *this;
0251   }
0252 
0253   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 duration& operator*=(const rep& __rhs) {
0254     __rep_ *= __rhs;
0255     return *this;
0256   }
0257   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 duration& operator/=(const rep& __rhs) {
0258     __rep_ /= __rhs;
0259     return *this;
0260   }
0261   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 duration& operator%=(const rep& __rhs) {
0262     __rep_ %= __rhs;
0263     return *this;
0264   }
0265   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 duration& operator%=(const duration& __rhs) {
0266     __rep_ %= __rhs.count();
0267     return *this;
0268   }
0269 
0270   // special values
0271 
0272   _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR duration zero() _NOEXCEPT {
0273     return duration(duration_values<rep>::zero());
0274   }
0275   _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR duration min() _NOEXCEPT {
0276     return duration(duration_values<rep>::min());
0277   }
0278   _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR duration max() _NOEXCEPT {
0279     return duration(duration_values<rep>::max());
0280   }
0281 };
0282 
0283 typedef duration<long long, nano> nanoseconds;
0284 typedef duration<long long, micro> microseconds;
0285 typedef duration<long long, milli> milliseconds;
0286 typedef duration<long long > seconds;
0287 typedef duration< long, ratio< 60> > minutes;
0288 typedef duration< long, ratio<3600> > hours;
0289 #if _LIBCPP_STD_VER >= 20
0290 typedef duration< int, ratio_multiply<ratio<24>, hours::period>> days;
0291 typedef duration< int, ratio_multiply<ratio<7>, days::period>> weeks;
0292 typedef duration< int, ratio_multiply<ratio<146097, 400>, days::period>> years;
0293 typedef duration< int, ratio_divide<years::period, ratio<12>>> months;
0294 #endif
0295 // Duration ==
0296 
0297 template <class _LhsDuration, class _RhsDuration>
0298 struct __duration_eq {
0299   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator()(const _LhsDuration& __lhs, const _RhsDuration& __rhs) const {
0300     typedef typename common_type<_LhsDuration, _RhsDuration>::type _Ct;
0301     return _Ct(__lhs).count() == _Ct(__rhs).count();
0302   }
0303 };
0304 
0305 template <class _LhsDuration>
0306 struct __duration_eq<_LhsDuration, _LhsDuration> {
0307   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator()(const _LhsDuration& __lhs, const _LhsDuration& __rhs) const {
0308     return __lhs.count() == __rhs.count();
0309   }
0310 };
0311 
0312 template <class _Rep1, class _Period1, class _Rep2, class _Period2>
0313 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool
0314 operator==(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) {
0315   return __duration_eq<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >()(__lhs, __rhs);
0316 }
0317 
0318 #if _LIBCPP_STD_VER <= 17
0319 
0320 // Duration !=
0321 
0322 template <class _Rep1, class _Period1, class _Rep2, class _Period2>
0323 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool
0324 operator!=(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) {
0325   return !(__lhs == __rhs);
0326 }
0327 
0328 #endif // _LIBCPP_STD_VER <= 17
0329 
0330 // Duration <
0331 
0332 template <class _LhsDuration, class _RhsDuration>
0333 struct __duration_lt {
0334   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator()(const _LhsDuration& __lhs, const _RhsDuration& __rhs) const {
0335     typedef typename common_type<_LhsDuration, _RhsDuration>::type _Ct;
0336     return _Ct(__lhs).count() < _Ct(__rhs).count();
0337   }
0338 };
0339 
0340 template <class _LhsDuration>
0341 struct __duration_lt<_LhsDuration, _LhsDuration> {
0342   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator()(const _LhsDuration& __lhs, const _LhsDuration& __rhs) const {
0343     return __lhs.count() < __rhs.count();
0344   }
0345 };
0346 
0347 template <class _Rep1, class _Period1, class _Rep2, class _Period2>
0348 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool
0349 operator<(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) {
0350   return __duration_lt<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >()(__lhs, __rhs);
0351 }
0352 
0353 // Duration >
0354 
0355 template <class _Rep1, class _Period1, class _Rep2, class _Period2>
0356 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool
0357 operator>(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) {
0358   return __rhs < __lhs;
0359 }
0360 
0361 // Duration <=
0362 
0363 template <class _Rep1, class _Period1, class _Rep2, class _Period2>
0364 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool
0365 operator<=(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) {
0366   return !(__rhs < __lhs);
0367 }
0368 
0369 // Duration >=
0370 
0371 template <class _Rep1, class _Period1, class _Rep2, class _Period2>
0372 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool
0373 operator>=(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) {
0374   return !(__lhs < __rhs);
0375 }
0376 
0377 #if _LIBCPP_STD_VER >= 20
0378 
0379 template <class _Rep1, class _Period1, class _Rep2, class _Period2>
0380   requires three_way_comparable<common_type_t<_Rep1, _Rep2>>
0381 _LIBCPP_HIDE_FROM_ABI constexpr auto
0382 operator<=>(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) {
0383   using _Ct = common_type_t<duration<_Rep1, _Period1>, duration<_Rep2, _Period2>>;
0384   return _Ct(__lhs).count() <=> _Ct(__rhs).count();
0385 }
0386 
0387 #endif // _LIBCPP_STD_VER >= 20
0388 
0389 // Duration +
0390 
0391 template <class _Rep1, class _Period1, class _Rep2, class _Period2>
0392 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR
0393 typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type
0394 operator+(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) {
0395   typedef typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type _Cd;
0396   return _Cd(_Cd(__lhs).count() + _Cd(__rhs).count());
0397 }
0398 
0399 // Duration -
0400 
0401 template <class _Rep1, class _Period1, class _Rep2, class _Period2>
0402 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR
0403 typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type
0404 operator-(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) {
0405   typedef typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type _Cd;
0406   return _Cd(_Cd(__lhs).count() - _Cd(__rhs).count());
0407 }
0408 
0409 // Duration *
0410 
0411 template <class _Rep1,
0412           class _Period,
0413           class _Rep2,
0414           __enable_if_t<is_convertible<const _Rep2&, typename common_type<_Rep1, _Rep2>::type>::value, int> = 0>
0415 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR duration<typename common_type<_Rep1, _Rep2>::type, _Period>
0416 operator*(const duration<_Rep1, _Period>& __d, const _Rep2& __s) {
0417   typedef typename common_type<_Rep1, _Rep2>::type _Cr;
0418   typedef duration<_Cr, _Period> _Cd;
0419   return _Cd(_Cd(__d).count() * static_cast<_Cr>(__s));
0420 }
0421 
0422 template <class _Rep1,
0423           class _Period,
0424           class _Rep2,
0425           __enable_if_t<is_convertible<const _Rep1&, typename common_type<_Rep1, _Rep2>::type>::value, int> = 0>
0426 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR duration<typename common_type<_Rep1, _Rep2>::type, _Period>
0427 operator*(const _Rep1& __s, const duration<_Rep2, _Period>& __d) {
0428   return __d * __s;
0429 }
0430 
0431 // Duration /
0432 
0433 template <class _Rep1,
0434           class _Period,
0435           class _Rep2,
0436           __enable_if_t<!__is_duration_v<_Rep2> &&
0437                             is_convertible<const _Rep2&, typename common_type<_Rep1, _Rep2>::type>::value,
0438                         int> = 0>
0439 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR duration<typename common_type<_Rep1, _Rep2>::type, _Period>
0440 operator/(const duration<_Rep1, _Period>& __d, const _Rep2& __s) {
0441   typedef typename common_type<_Rep1, _Rep2>::type _Cr;
0442   typedef duration<_Cr, _Period> _Cd;
0443   return _Cd(_Cd(__d).count() / static_cast<_Cr>(__s));
0444 }
0445 
0446 template <class _Rep1, class _Period1, class _Rep2, class _Period2>
0447 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR typename common_type<_Rep1, _Rep2>::type
0448 operator/(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) {
0449   typedef typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type _Ct;
0450   return _Ct(__lhs).count() / _Ct(__rhs).count();
0451 }
0452 
0453 // Duration %
0454 
0455 template <class _Rep1,
0456           class _Period,
0457           class _Rep2,
0458           __enable_if_t<!__is_duration_v<_Rep2> &&
0459                             is_convertible<const _Rep2&, typename common_type<_Rep1, _Rep2>::type>::value,
0460                         int> = 0>
0461 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR duration<typename common_type<_Rep1, _Rep2>::type, _Period>
0462 operator%(const duration<_Rep1, _Period>& __d, const _Rep2& __s) {
0463   typedef typename common_type<_Rep1, _Rep2>::type _Cr;
0464   typedef duration<_Cr, _Period> _Cd;
0465   return _Cd(_Cd(__d).count() % static_cast<_Cr>(__s));
0466 }
0467 
0468 template <class _Rep1, class _Period1, class _Rep2, class _Period2>
0469 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR
0470 typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type
0471 operator%(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) {
0472   typedef typename common_type<_Rep1, _Rep2>::type _Cr;
0473   typedef typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type _Cd;
0474   return _Cd(static_cast<_Cr>(_Cd(__lhs).count()) % static_cast<_Cr>(_Cd(__rhs).count()));
0475 }
0476 
0477 } // namespace chrono
0478 
0479 #if _LIBCPP_STD_VER >= 14
0480 // Suffixes for duration literals [time.duration.literals]
0481 inline namespace literals {
0482 inline namespace chrono_literals {
0483 
0484 _LIBCPP_HIDE_FROM_ABI constexpr chrono::hours operator""h(unsigned long long __h) {
0485   return chrono::hours(static_cast<chrono::hours::rep>(__h));
0486 }
0487 
0488 _LIBCPP_HIDE_FROM_ABI constexpr chrono::duration<long double, ratio<3600, 1>> operator""h(long double __h) {
0489   return chrono::duration<long double, ratio<3600, 1>>(__h);
0490 }
0491 
0492 _LIBCPP_HIDE_FROM_ABI constexpr chrono::minutes operator""min(unsigned long long __m) {
0493   return chrono::minutes(static_cast<chrono::minutes::rep>(__m));
0494 }
0495 
0496 _LIBCPP_HIDE_FROM_ABI constexpr chrono::duration<long double, ratio<60, 1>> operator""min(long double __m) {
0497   return chrono::duration<long double, ratio<60, 1>>(__m);
0498 }
0499 
0500 _LIBCPP_HIDE_FROM_ABI constexpr chrono::seconds operator""s(unsigned long long __s) {
0501   return chrono::seconds(static_cast<chrono::seconds::rep>(__s));
0502 }
0503 
0504 _LIBCPP_HIDE_FROM_ABI constexpr chrono::duration<long double> operator""s(long double __s) {
0505   return chrono::duration<long double>(__s);
0506 }
0507 
0508 _LIBCPP_HIDE_FROM_ABI constexpr chrono::milliseconds operator""ms(unsigned long long __ms) {
0509   return chrono::milliseconds(static_cast<chrono::milliseconds::rep>(__ms));
0510 }
0511 
0512 _LIBCPP_HIDE_FROM_ABI constexpr chrono::duration<long double, milli> operator""ms(long double __ms) {
0513   return chrono::duration<long double, milli>(__ms);
0514 }
0515 
0516 _LIBCPP_HIDE_FROM_ABI constexpr chrono::microseconds operator""us(unsigned long long __us) {
0517   return chrono::microseconds(static_cast<chrono::microseconds::rep>(__us));
0518 }
0519 
0520 _LIBCPP_HIDE_FROM_ABI constexpr chrono::duration<long double, micro> operator""us(long double __us) {
0521   return chrono::duration<long double, micro>(__us);
0522 }
0523 
0524 _LIBCPP_HIDE_FROM_ABI constexpr chrono::nanoseconds operator""ns(unsigned long long __ns) {
0525   return chrono::nanoseconds(static_cast<chrono::nanoseconds::rep>(__ns));
0526 }
0527 
0528 _LIBCPP_HIDE_FROM_ABI constexpr chrono::duration<long double, nano> operator""ns(long double __ns) {
0529   return chrono::duration<long double, nano>(__ns);
0530 }
0531 
0532 } // namespace chrono_literals
0533 } // namespace literals
0534 
0535 namespace chrono { // hoist the literals into namespace std::chrono
0536 using namespace literals::chrono_literals;
0537 } // namespace chrono
0538 
0539 #endif // _LIBCPP_STD_VER >= 14
0540 
0541 _LIBCPP_END_NAMESPACE_STD
0542 
0543 _LIBCPP_POP_MACROS
0544 
0545 #endif // _LIBCPP___CHRONO_DURATION_H