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