104eeddc0SDimitry Andric // -*- C++ -*- 204eeddc0SDimitry Andric //===----------------------------------------------------------------------===// 304eeddc0SDimitry Andric // 404eeddc0SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 504eeddc0SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 604eeddc0SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 704eeddc0SDimitry Andric // 804eeddc0SDimitry Andric //===----------------------------------------------------------------------===// 904eeddc0SDimitry Andric 1004eeddc0SDimitry Andric #ifndef _LIBCPP___CHRONO_DURATION_H 1104eeddc0SDimitry Andric #define _LIBCPP___CHRONO_DURATION_H 1204eeddc0SDimitry Andric 13*06c3fb27SDimitry Andric #include <__compare/ordering.h> 14*06c3fb27SDimitry Andric #include <__compare/three_way_comparable.h> 1504eeddc0SDimitry Andric #include <__config> 16bdd1243dSDimitry Andric #include <__type_traits/common_type.h> 17bdd1243dSDimitry Andric #include <__type_traits/enable_if.h> 18bdd1243dSDimitry Andric #include <__type_traits/is_convertible.h> 19bdd1243dSDimitry Andric #include <__type_traits/is_floating_point.h> 2004eeddc0SDimitry Andric #include <limits> 2104eeddc0SDimitry Andric #include <ratio> 2204eeddc0SDimitry Andric 2304eeddc0SDimitry Andric #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 2404eeddc0SDimitry Andric # pragma GCC system_header 2504eeddc0SDimitry Andric #endif 2604eeddc0SDimitry Andric 2704eeddc0SDimitry Andric _LIBCPP_PUSH_MACROS 2804eeddc0SDimitry Andric #include <__undef_macros> 2904eeddc0SDimitry Andric 3004eeddc0SDimitry Andric _LIBCPP_BEGIN_NAMESPACE_STD 3104eeddc0SDimitry Andric 3204eeddc0SDimitry Andric namespace chrono 3304eeddc0SDimitry Andric { 3404eeddc0SDimitry Andric 3504eeddc0SDimitry Andric template <class _Rep, class _Period = ratio<1> > class _LIBCPP_TEMPLATE_VIS duration; 3604eeddc0SDimitry Andric 3704eeddc0SDimitry Andric template <class _Tp> 3804eeddc0SDimitry Andric struct __is_duration : false_type {}; 3904eeddc0SDimitry Andric 4004eeddc0SDimitry Andric template <class _Rep, class _Period> 4104eeddc0SDimitry Andric struct __is_duration<duration<_Rep, _Period> > : true_type {}; 4204eeddc0SDimitry Andric 4304eeddc0SDimitry Andric template <class _Rep, class _Period> 4404eeddc0SDimitry Andric struct __is_duration<const duration<_Rep, _Period> > : true_type {}; 4504eeddc0SDimitry Andric 4604eeddc0SDimitry Andric template <class _Rep, class _Period> 4704eeddc0SDimitry Andric struct __is_duration<volatile duration<_Rep, _Period> > : true_type {}; 4804eeddc0SDimitry Andric 4904eeddc0SDimitry Andric template <class _Rep, class _Period> 5004eeddc0SDimitry Andric struct __is_duration<const volatile duration<_Rep, _Period> > : true_type {}; 5104eeddc0SDimitry Andric 5204eeddc0SDimitry Andric } // namespace chrono 5304eeddc0SDimitry Andric 5404eeddc0SDimitry Andric template <class _Rep1, class _Period1, class _Rep2, class _Period2> 5504eeddc0SDimitry Andric struct _LIBCPP_TEMPLATE_VIS common_type<chrono::duration<_Rep1, _Period1>, 5604eeddc0SDimitry Andric chrono::duration<_Rep2, _Period2> > 5704eeddc0SDimitry Andric { 5804eeddc0SDimitry Andric typedef chrono::duration<typename common_type<_Rep1, _Rep2>::type, 5904eeddc0SDimitry Andric typename __ratio_gcd<_Period1, _Period2>::type> type; 6004eeddc0SDimitry Andric }; 6104eeddc0SDimitry Andric 6204eeddc0SDimitry Andric namespace chrono { 6304eeddc0SDimitry Andric 6404eeddc0SDimitry Andric // duration_cast 6504eeddc0SDimitry Andric 6604eeddc0SDimitry Andric template <class _FromDuration, class _ToDuration, 6704eeddc0SDimitry Andric class _Period = typename ratio_divide<typename _FromDuration::period, typename _ToDuration::period>::type, 6804eeddc0SDimitry Andric bool = _Period::num == 1, 6904eeddc0SDimitry Andric bool = _Period::den == 1> 7004eeddc0SDimitry Andric struct __duration_cast; 7104eeddc0SDimitry Andric 7204eeddc0SDimitry Andric template <class _FromDuration, class _ToDuration, class _Period> 7304eeddc0SDimitry Andric struct __duration_cast<_FromDuration, _ToDuration, _Period, true, true> 7404eeddc0SDimitry Andric { 7504eeddc0SDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR 7604eeddc0SDimitry Andric _ToDuration operator()(const _FromDuration& __fd) const 7704eeddc0SDimitry Andric { 7804eeddc0SDimitry Andric return _ToDuration(static_cast<typename _ToDuration::rep>(__fd.count())); 7904eeddc0SDimitry Andric } 8004eeddc0SDimitry Andric }; 8104eeddc0SDimitry Andric 8204eeddc0SDimitry Andric template <class _FromDuration, class _ToDuration, class _Period> 8304eeddc0SDimitry Andric struct __duration_cast<_FromDuration, _ToDuration, _Period, true, false> 8404eeddc0SDimitry Andric { 8504eeddc0SDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR 8604eeddc0SDimitry Andric _ToDuration operator()(const _FromDuration& __fd) const 8704eeddc0SDimitry Andric { 8804eeddc0SDimitry Andric typedef typename common_type<typename _ToDuration::rep, typename _FromDuration::rep, intmax_t>::type _Ct; 8904eeddc0SDimitry Andric return _ToDuration(static_cast<typename _ToDuration::rep>( 9004eeddc0SDimitry Andric static_cast<_Ct>(__fd.count()) / static_cast<_Ct>(_Period::den))); 9104eeddc0SDimitry Andric } 9204eeddc0SDimitry Andric }; 9304eeddc0SDimitry Andric 9404eeddc0SDimitry Andric template <class _FromDuration, class _ToDuration, class _Period> 9504eeddc0SDimitry Andric struct __duration_cast<_FromDuration, _ToDuration, _Period, false, true> 9604eeddc0SDimitry Andric { 9704eeddc0SDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR 9804eeddc0SDimitry Andric _ToDuration operator()(const _FromDuration& __fd) const 9904eeddc0SDimitry Andric { 10004eeddc0SDimitry Andric typedef typename common_type<typename _ToDuration::rep, typename _FromDuration::rep, intmax_t>::type _Ct; 10104eeddc0SDimitry Andric return _ToDuration(static_cast<typename _ToDuration::rep>( 10204eeddc0SDimitry Andric static_cast<_Ct>(__fd.count()) * static_cast<_Ct>(_Period::num))); 10304eeddc0SDimitry Andric } 10404eeddc0SDimitry Andric }; 10504eeddc0SDimitry Andric 10604eeddc0SDimitry Andric template <class _FromDuration, class _ToDuration, class _Period> 10704eeddc0SDimitry Andric struct __duration_cast<_FromDuration, _ToDuration, _Period, false, false> 10804eeddc0SDimitry Andric { 10904eeddc0SDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR 11004eeddc0SDimitry Andric _ToDuration operator()(const _FromDuration& __fd) const 11104eeddc0SDimitry Andric { 11204eeddc0SDimitry Andric typedef typename common_type<typename _ToDuration::rep, typename _FromDuration::rep, intmax_t>::type _Ct; 11304eeddc0SDimitry Andric return _ToDuration(static_cast<typename _ToDuration::rep>( 11404eeddc0SDimitry Andric static_cast<_Ct>(__fd.count()) * static_cast<_Ct>(_Period::num) 11504eeddc0SDimitry Andric / static_cast<_Ct>(_Period::den))); 11604eeddc0SDimitry Andric } 11704eeddc0SDimitry Andric }; 11804eeddc0SDimitry Andric 11904eeddc0SDimitry Andric template <class _ToDuration, class _Rep, class _Period> 12004eeddc0SDimitry Andric inline _LIBCPP_INLINE_VISIBILITY 12104eeddc0SDimitry Andric _LIBCPP_CONSTEXPR 12204eeddc0SDimitry Andric typename enable_if 12304eeddc0SDimitry Andric < 12404eeddc0SDimitry Andric __is_duration<_ToDuration>::value, 12504eeddc0SDimitry Andric _ToDuration 12604eeddc0SDimitry Andric >::type 12704eeddc0SDimitry Andric duration_cast(const duration<_Rep, _Period>& __fd) 12804eeddc0SDimitry Andric { 12904eeddc0SDimitry Andric return __duration_cast<duration<_Rep, _Period>, _ToDuration>()(__fd); 13004eeddc0SDimitry Andric } 13104eeddc0SDimitry Andric 13204eeddc0SDimitry Andric template <class _Rep> 13304eeddc0SDimitry Andric struct _LIBCPP_TEMPLATE_VIS treat_as_floating_point : is_floating_point<_Rep> {}; 13404eeddc0SDimitry Andric 135*06c3fb27SDimitry Andric #if _LIBCPP_STD_VER >= 17 13604eeddc0SDimitry Andric template <class _Rep> 13704eeddc0SDimitry Andric inline constexpr bool treat_as_floating_point_v = treat_as_floating_point<_Rep>::value; 13804eeddc0SDimitry Andric #endif 13904eeddc0SDimitry Andric 14004eeddc0SDimitry Andric template <class _Rep> 14104eeddc0SDimitry Andric struct _LIBCPP_TEMPLATE_VIS duration_values 14204eeddc0SDimitry Andric { 14304eeddc0SDimitry Andric public: 14404eeddc0SDimitry Andric _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR _Rep zero() _NOEXCEPT {return _Rep(0);} 14504eeddc0SDimitry Andric _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR _Rep max() _NOEXCEPT {return numeric_limits<_Rep>::max();} 14604eeddc0SDimitry Andric _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR _Rep min() _NOEXCEPT {return numeric_limits<_Rep>::lowest();} 14704eeddc0SDimitry Andric }; 14804eeddc0SDimitry Andric 149*06c3fb27SDimitry Andric #if _LIBCPP_STD_VER >= 17 15004eeddc0SDimitry Andric template <class _ToDuration, class _Rep, class _Period> 15104eeddc0SDimitry Andric inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR 15204eeddc0SDimitry Andric typename enable_if 15304eeddc0SDimitry Andric < 15404eeddc0SDimitry Andric __is_duration<_ToDuration>::value, 15504eeddc0SDimitry Andric _ToDuration 15604eeddc0SDimitry Andric >::type 15704eeddc0SDimitry Andric floor(const duration<_Rep, _Period>& __d) 15804eeddc0SDimitry Andric { 159bdd1243dSDimitry Andric _ToDuration __t = chrono::duration_cast<_ToDuration>(__d); 16004eeddc0SDimitry Andric if (__t > __d) 16104eeddc0SDimitry Andric __t = __t - _ToDuration{1}; 16204eeddc0SDimitry Andric return __t; 16304eeddc0SDimitry Andric } 16404eeddc0SDimitry Andric 16504eeddc0SDimitry Andric template <class _ToDuration, class _Rep, class _Period> 16604eeddc0SDimitry Andric inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR 16704eeddc0SDimitry Andric typename enable_if 16804eeddc0SDimitry Andric < 16904eeddc0SDimitry Andric __is_duration<_ToDuration>::value, 17004eeddc0SDimitry Andric _ToDuration 17104eeddc0SDimitry Andric >::type 17204eeddc0SDimitry Andric ceil(const duration<_Rep, _Period>& __d) 17304eeddc0SDimitry Andric { 174bdd1243dSDimitry Andric _ToDuration __t = chrono::duration_cast<_ToDuration>(__d); 17504eeddc0SDimitry Andric if (__t < __d) 17604eeddc0SDimitry Andric __t = __t + _ToDuration{1}; 17704eeddc0SDimitry Andric return __t; 17804eeddc0SDimitry Andric } 17904eeddc0SDimitry Andric 18004eeddc0SDimitry Andric template <class _ToDuration, class _Rep, class _Period> 18104eeddc0SDimitry Andric inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR 18204eeddc0SDimitry Andric typename enable_if 18304eeddc0SDimitry Andric < 18404eeddc0SDimitry Andric __is_duration<_ToDuration>::value, 18504eeddc0SDimitry Andric _ToDuration 18604eeddc0SDimitry Andric >::type 18704eeddc0SDimitry Andric round(const duration<_Rep, _Period>& __d) 18804eeddc0SDimitry Andric { 189bdd1243dSDimitry Andric _ToDuration __lower = chrono::floor<_ToDuration>(__d); 19004eeddc0SDimitry Andric _ToDuration __upper = __lower + _ToDuration{1}; 191*06c3fb27SDimitry Andric auto __lower_diff = __d - __lower; 192*06c3fb27SDimitry Andric auto __upper_diff = __upper - __d; 193*06c3fb27SDimitry Andric if (__lower_diff < __upper_diff) 19404eeddc0SDimitry Andric return __lower; 195*06c3fb27SDimitry Andric if (__lower_diff > __upper_diff) 19604eeddc0SDimitry Andric return __upper; 19704eeddc0SDimitry Andric return __lower.count() & 1 ? __upper : __lower; 19804eeddc0SDimitry Andric } 19904eeddc0SDimitry Andric #endif 20004eeddc0SDimitry Andric 20104eeddc0SDimitry Andric // duration 20204eeddc0SDimitry Andric 20304eeddc0SDimitry Andric template <class _Rep, class _Period> 20404eeddc0SDimitry Andric class _LIBCPP_TEMPLATE_VIS duration 20504eeddc0SDimitry Andric { 20604eeddc0SDimitry Andric static_assert(!__is_duration<_Rep>::value, "A duration representation can not be a duration"); 20704eeddc0SDimitry Andric static_assert(__is_ratio<_Period>::value, "Second template parameter of duration must be a std::ratio"); 20804eeddc0SDimitry Andric static_assert(_Period::num > 0, "duration period must be positive"); 20904eeddc0SDimitry Andric 21004eeddc0SDimitry Andric template <class _R1, class _R2> 21104eeddc0SDimitry Andric struct __no_overflow 21204eeddc0SDimitry Andric { 21304eeddc0SDimitry Andric private: 21404eeddc0SDimitry Andric static const intmax_t __gcd_n1_n2 = __static_gcd<_R1::num, _R2::num>::value; 21504eeddc0SDimitry Andric static const intmax_t __gcd_d1_d2 = __static_gcd<_R1::den, _R2::den>::value; 21604eeddc0SDimitry Andric static const intmax_t __n1 = _R1::num / __gcd_n1_n2; 21704eeddc0SDimitry Andric static const intmax_t __d1 = _R1::den / __gcd_d1_d2; 21804eeddc0SDimitry Andric static const intmax_t __n2 = _R2::num / __gcd_n1_n2; 21904eeddc0SDimitry Andric static const intmax_t __d2 = _R2::den / __gcd_d1_d2; 22004eeddc0SDimitry Andric static const intmax_t max = -((intmax_t(1) << (sizeof(intmax_t) * CHAR_BIT - 1)) + 1); 22104eeddc0SDimitry Andric 22204eeddc0SDimitry Andric template <intmax_t _Xp, intmax_t _Yp, bool __overflow> 22304eeddc0SDimitry Andric struct __mul // __overflow == false 22404eeddc0SDimitry Andric { 22504eeddc0SDimitry Andric static const intmax_t value = _Xp * _Yp; 22604eeddc0SDimitry Andric }; 22704eeddc0SDimitry Andric 22804eeddc0SDimitry Andric template <intmax_t _Xp, intmax_t _Yp> 22904eeddc0SDimitry Andric struct __mul<_Xp, _Yp, true> 23004eeddc0SDimitry Andric { 23104eeddc0SDimitry Andric static const intmax_t value = 1; 23204eeddc0SDimitry Andric }; 23304eeddc0SDimitry Andric 23404eeddc0SDimitry Andric public: 23504eeddc0SDimitry Andric static const bool value = (__n1 <= max / __d2) && (__n2 <= max / __d1); 23604eeddc0SDimitry Andric typedef ratio<__mul<__n1, __d2, !value>::value, 23704eeddc0SDimitry Andric __mul<__n2, __d1, !value>::value> type; 23804eeddc0SDimitry Andric }; 23904eeddc0SDimitry Andric 24004eeddc0SDimitry Andric public: 24104eeddc0SDimitry Andric typedef _Rep rep; 24204eeddc0SDimitry Andric typedef typename _Period::type period; 24304eeddc0SDimitry Andric private: 24404eeddc0SDimitry Andric rep __rep_; 24504eeddc0SDimitry Andric public: 24604eeddc0SDimitry Andric 24704eeddc0SDimitry Andric #ifndef _LIBCPP_CXX03_LANG 248*06c3fb27SDimitry Andric constexpr duration() = default; 24904eeddc0SDimitry Andric #else 250*06c3fb27SDimitry Andric _LIBCPP_HIDE_FROM_ABI duration() {} 25104eeddc0SDimitry Andric #endif 25204eeddc0SDimitry Andric 25304eeddc0SDimitry Andric template <class _Rep2> 25404eeddc0SDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR 25504eeddc0SDimitry Andric explicit duration(const _Rep2& __r, 25604eeddc0SDimitry Andric typename enable_if 25704eeddc0SDimitry Andric < 2581838bd0fSDimitry Andric is_convertible<const _Rep2&, rep>::value && 25904eeddc0SDimitry Andric (treat_as_floating_point<rep>::value || 26004eeddc0SDimitry Andric !treat_as_floating_point<_Rep2>::value) 26104eeddc0SDimitry Andric >::type* = nullptr) 26204eeddc0SDimitry Andric : __rep_(__r) {} 26304eeddc0SDimitry Andric 26404eeddc0SDimitry Andric // conversions 26504eeddc0SDimitry Andric template <class _Rep2, class _Period2> 26604eeddc0SDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR 26704eeddc0SDimitry Andric duration(const duration<_Rep2, _Period2>& __d, 26804eeddc0SDimitry Andric typename enable_if 26904eeddc0SDimitry Andric < 27004eeddc0SDimitry Andric __no_overflow<_Period2, period>::value && ( 27104eeddc0SDimitry Andric treat_as_floating_point<rep>::value || 27204eeddc0SDimitry Andric (__no_overflow<_Period2, period>::type::den == 1 && 27304eeddc0SDimitry Andric !treat_as_floating_point<_Rep2>::value)) 27404eeddc0SDimitry Andric >::type* = nullptr) 27504eeddc0SDimitry Andric : __rep_(chrono::duration_cast<duration>(__d).count()) {} 27604eeddc0SDimitry Andric 27704eeddc0SDimitry Andric // observer 27804eeddc0SDimitry Andric 27904eeddc0SDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR rep count() const {return __rep_;} 28004eeddc0SDimitry Andric 28104eeddc0SDimitry Andric // arithmetic 28204eeddc0SDimitry Andric 28304eeddc0SDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR typename common_type<duration>::type operator+() const {return typename common_type<duration>::type(*this);} 28404eeddc0SDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR typename common_type<duration>::type operator-() const {return typename common_type<duration>::type(-__rep_);} 285bdd1243dSDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17 duration& operator++() {++__rep_; return *this;} 286bdd1243dSDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17 duration operator++(int) {return duration(__rep_++);} 287bdd1243dSDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17 duration& operator--() {--__rep_; return *this;} 288bdd1243dSDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17 duration operator--(int) {return duration(__rep_--);} 28904eeddc0SDimitry Andric 290bdd1243dSDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17 duration& operator+=(const duration& __d) {__rep_ += __d.count(); return *this;} 291bdd1243dSDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17 duration& operator-=(const duration& __d) {__rep_ -= __d.count(); return *this;} 29204eeddc0SDimitry Andric 293bdd1243dSDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17 duration& operator*=(const rep& __rhs) {__rep_ *= __rhs; return *this;} 294bdd1243dSDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17 duration& operator/=(const rep& __rhs) {__rep_ /= __rhs; return *this;} 295bdd1243dSDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17 duration& operator%=(const rep& __rhs) {__rep_ %= __rhs; return *this;} 296bdd1243dSDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17 duration& operator%=(const duration& __rhs) {__rep_ %= __rhs.count(); return *this;} 29704eeddc0SDimitry Andric 29804eeddc0SDimitry Andric // special values 29904eeddc0SDimitry Andric 30004eeddc0SDimitry Andric _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR duration zero() _NOEXCEPT {return duration(duration_values<rep>::zero());} 30104eeddc0SDimitry Andric _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR duration min() _NOEXCEPT {return duration(duration_values<rep>::min());} 30204eeddc0SDimitry Andric _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR duration max() _NOEXCEPT {return duration(duration_values<rep>::max());} 30304eeddc0SDimitry Andric }; 30404eeddc0SDimitry Andric 30504eeddc0SDimitry Andric typedef duration<long long, nano> nanoseconds; 30604eeddc0SDimitry Andric typedef duration<long long, micro> microseconds; 30704eeddc0SDimitry Andric typedef duration<long long, milli> milliseconds; 30804eeddc0SDimitry Andric typedef duration<long long > seconds; 30904eeddc0SDimitry Andric typedef duration< long, ratio< 60> > minutes; 31004eeddc0SDimitry Andric typedef duration< long, ratio<3600> > hours; 311*06c3fb27SDimitry Andric #if _LIBCPP_STD_VER >= 20 31204eeddc0SDimitry Andric typedef duration< int, ratio_multiply<ratio<24>, hours::period>> days; 31304eeddc0SDimitry Andric typedef duration< int, ratio_multiply<ratio<7>, days::period>> weeks; 31404eeddc0SDimitry Andric typedef duration< int, ratio_multiply<ratio<146097, 400>, days::period>> years; 31504eeddc0SDimitry Andric typedef duration< int, ratio_divide<years::period, ratio<12>>> months; 31604eeddc0SDimitry Andric #endif 31704eeddc0SDimitry Andric // Duration == 31804eeddc0SDimitry Andric 31904eeddc0SDimitry Andric template <class _LhsDuration, class _RhsDuration> 32004eeddc0SDimitry Andric struct __duration_eq 32104eeddc0SDimitry Andric { 32204eeddc0SDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR 32304eeddc0SDimitry Andric bool operator()(const _LhsDuration& __lhs, const _RhsDuration& __rhs) const 32404eeddc0SDimitry Andric { 32504eeddc0SDimitry Andric typedef typename common_type<_LhsDuration, _RhsDuration>::type _Ct; 32604eeddc0SDimitry Andric return _Ct(__lhs).count() == _Ct(__rhs).count(); 32704eeddc0SDimitry Andric } 32804eeddc0SDimitry Andric }; 32904eeddc0SDimitry Andric 33004eeddc0SDimitry Andric template <class _LhsDuration> 33104eeddc0SDimitry Andric struct __duration_eq<_LhsDuration, _LhsDuration> 33204eeddc0SDimitry Andric { 33304eeddc0SDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR 33404eeddc0SDimitry Andric bool operator()(const _LhsDuration& __lhs, const _LhsDuration& __rhs) const 33504eeddc0SDimitry Andric {return __lhs.count() == __rhs.count();} 33604eeddc0SDimitry Andric }; 33704eeddc0SDimitry Andric 33804eeddc0SDimitry Andric template <class _Rep1, class _Period1, class _Rep2, class _Period2> 33904eeddc0SDimitry Andric inline _LIBCPP_INLINE_VISIBILITY 34004eeddc0SDimitry Andric _LIBCPP_CONSTEXPR 34104eeddc0SDimitry Andric bool 34204eeddc0SDimitry Andric operator==(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) 34304eeddc0SDimitry Andric { 34404eeddc0SDimitry Andric return __duration_eq<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >()(__lhs, __rhs); 34504eeddc0SDimitry Andric } 34604eeddc0SDimitry Andric 347*06c3fb27SDimitry Andric #if _LIBCPP_STD_VER <= 17 348*06c3fb27SDimitry Andric 34904eeddc0SDimitry Andric // Duration != 35004eeddc0SDimitry Andric 35104eeddc0SDimitry Andric template <class _Rep1, class _Period1, class _Rep2, class _Period2> 35204eeddc0SDimitry Andric inline _LIBCPP_INLINE_VISIBILITY 35304eeddc0SDimitry Andric _LIBCPP_CONSTEXPR 35404eeddc0SDimitry Andric bool 35504eeddc0SDimitry Andric operator!=(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) 35604eeddc0SDimitry Andric { 35704eeddc0SDimitry Andric return !(__lhs == __rhs); 35804eeddc0SDimitry Andric } 35904eeddc0SDimitry Andric 360*06c3fb27SDimitry Andric #endif // _LIBCPP_STD_VER <= 17 361*06c3fb27SDimitry Andric 36204eeddc0SDimitry Andric // Duration < 36304eeddc0SDimitry Andric 36404eeddc0SDimitry Andric template <class _LhsDuration, class _RhsDuration> 36504eeddc0SDimitry Andric struct __duration_lt 36604eeddc0SDimitry Andric { 36704eeddc0SDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR 36804eeddc0SDimitry Andric bool operator()(const _LhsDuration& __lhs, const _RhsDuration& __rhs) const 36904eeddc0SDimitry Andric { 37004eeddc0SDimitry Andric typedef typename common_type<_LhsDuration, _RhsDuration>::type _Ct; 37104eeddc0SDimitry Andric return _Ct(__lhs).count() < _Ct(__rhs).count(); 37204eeddc0SDimitry Andric } 37304eeddc0SDimitry Andric }; 37404eeddc0SDimitry Andric 37504eeddc0SDimitry Andric template <class _LhsDuration> 37604eeddc0SDimitry Andric struct __duration_lt<_LhsDuration, _LhsDuration> 37704eeddc0SDimitry Andric { 37804eeddc0SDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR 37904eeddc0SDimitry Andric bool operator()(const _LhsDuration& __lhs, const _LhsDuration& __rhs) const 38004eeddc0SDimitry Andric {return __lhs.count() < __rhs.count();} 38104eeddc0SDimitry Andric }; 38204eeddc0SDimitry Andric 38304eeddc0SDimitry Andric template <class _Rep1, class _Period1, class _Rep2, class _Period2> 38404eeddc0SDimitry Andric inline _LIBCPP_INLINE_VISIBILITY 38504eeddc0SDimitry Andric _LIBCPP_CONSTEXPR 38604eeddc0SDimitry Andric bool 38704eeddc0SDimitry Andric operator< (const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) 38804eeddc0SDimitry Andric { 38904eeddc0SDimitry Andric return __duration_lt<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >()(__lhs, __rhs); 39004eeddc0SDimitry Andric } 39104eeddc0SDimitry Andric 39204eeddc0SDimitry Andric // Duration > 39304eeddc0SDimitry Andric 39404eeddc0SDimitry Andric template <class _Rep1, class _Period1, class _Rep2, class _Period2> 39504eeddc0SDimitry Andric inline _LIBCPP_INLINE_VISIBILITY 39604eeddc0SDimitry Andric _LIBCPP_CONSTEXPR 39704eeddc0SDimitry Andric bool 39804eeddc0SDimitry Andric operator> (const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) 39904eeddc0SDimitry Andric { 40004eeddc0SDimitry Andric return __rhs < __lhs; 40104eeddc0SDimitry Andric } 40204eeddc0SDimitry Andric 40304eeddc0SDimitry Andric // Duration <= 40404eeddc0SDimitry Andric 40504eeddc0SDimitry Andric template <class _Rep1, class _Period1, class _Rep2, class _Period2> 40604eeddc0SDimitry Andric inline _LIBCPP_INLINE_VISIBILITY 40704eeddc0SDimitry Andric _LIBCPP_CONSTEXPR 40804eeddc0SDimitry Andric bool 40904eeddc0SDimitry Andric operator<=(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) 41004eeddc0SDimitry Andric { 41104eeddc0SDimitry Andric return !(__rhs < __lhs); 41204eeddc0SDimitry Andric } 41304eeddc0SDimitry Andric 41404eeddc0SDimitry Andric // Duration >= 41504eeddc0SDimitry Andric 41604eeddc0SDimitry Andric template <class _Rep1, class _Period1, class _Rep2, class _Period2> 41704eeddc0SDimitry Andric inline _LIBCPP_INLINE_VISIBILITY 41804eeddc0SDimitry Andric _LIBCPP_CONSTEXPR 41904eeddc0SDimitry Andric bool 42004eeddc0SDimitry Andric operator>=(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) 42104eeddc0SDimitry Andric { 42204eeddc0SDimitry Andric return !(__lhs < __rhs); 42304eeddc0SDimitry Andric } 42404eeddc0SDimitry Andric 425*06c3fb27SDimitry Andric #if _LIBCPP_STD_VER >= 20 426*06c3fb27SDimitry Andric 427*06c3fb27SDimitry Andric template<class _Rep1, class _Period1, class _Rep2, class _Period2> 428*06c3fb27SDimitry Andric requires three_way_comparable<common_type_t<_Rep1, _Rep2>> 429*06c3fb27SDimitry Andric _LIBCPP_HIDE_FROM_ABI 430*06c3fb27SDimitry Andric constexpr auto operator<=>(const duration<_Rep1, _Period1>& __lhs, 431*06c3fb27SDimitry Andric const duration<_Rep2, _Period2>& __rhs) 432*06c3fb27SDimitry Andric { 433*06c3fb27SDimitry Andric using _Ct = common_type_t<duration<_Rep1, _Period1>, duration<_Rep2, _Period2>>; 434*06c3fb27SDimitry Andric return _Ct(__lhs).count() <=> _Ct(__rhs).count(); 435*06c3fb27SDimitry Andric } 436*06c3fb27SDimitry Andric 437*06c3fb27SDimitry Andric #endif // _LIBCPP_STD_VER >= 20 438*06c3fb27SDimitry Andric 43904eeddc0SDimitry Andric // Duration + 44004eeddc0SDimitry Andric 44104eeddc0SDimitry Andric template <class _Rep1, class _Period1, class _Rep2, class _Period2> 44204eeddc0SDimitry Andric inline _LIBCPP_INLINE_VISIBILITY 44304eeddc0SDimitry Andric _LIBCPP_CONSTEXPR 44404eeddc0SDimitry Andric typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type 44504eeddc0SDimitry Andric operator+(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) 44604eeddc0SDimitry Andric { 44704eeddc0SDimitry Andric typedef typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type _Cd; 44804eeddc0SDimitry Andric return _Cd(_Cd(__lhs).count() + _Cd(__rhs).count()); 44904eeddc0SDimitry Andric } 45004eeddc0SDimitry Andric 45104eeddc0SDimitry Andric // Duration - 45204eeddc0SDimitry Andric 45304eeddc0SDimitry Andric template <class _Rep1, class _Period1, class _Rep2, class _Period2> 45404eeddc0SDimitry Andric inline _LIBCPP_INLINE_VISIBILITY 45504eeddc0SDimitry Andric _LIBCPP_CONSTEXPR 45604eeddc0SDimitry Andric typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type 45704eeddc0SDimitry Andric operator-(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) 45804eeddc0SDimitry Andric { 45904eeddc0SDimitry Andric typedef typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type _Cd; 46004eeddc0SDimitry Andric return _Cd(_Cd(__lhs).count() - _Cd(__rhs).count()); 46104eeddc0SDimitry Andric } 46204eeddc0SDimitry Andric 46304eeddc0SDimitry Andric // Duration * 46404eeddc0SDimitry Andric 46504eeddc0SDimitry Andric template <class _Rep1, class _Period, class _Rep2> 46604eeddc0SDimitry Andric inline _LIBCPP_INLINE_VISIBILITY 46704eeddc0SDimitry Andric _LIBCPP_CONSTEXPR 46804eeddc0SDimitry Andric typename enable_if 46904eeddc0SDimitry Andric < 47004eeddc0SDimitry Andric is_convertible<_Rep2, typename common_type<_Rep1, _Rep2>::type>::value, 47104eeddc0SDimitry Andric duration<typename common_type<_Rep1, _Rep2>::type, _Period> 47204eeddc0SDimitry Andric >::type 47304eeddc0SDimitry Andric operator*(const duration<_Rep1, _Period>& __d, const _Rep2& __s) 47404eeddc0SDimitry Andric { 47504eeddc0SDimitry Andric typedef typename common_type<_Rep1, _Rep2>::type _Cr; 47604eeddc0SDimitry Andric typedef duration<_Cr, _Period> _Cd; 47704eeddc0SDimitry Andric return _Cd(_Cd(__d).count() * static_cast<_Cr>(__s)); 47804eeddc0SDimitry Andric } 47904eeddc0SDimitry Andric 48004eeddc0SDimitry Andric template <class _Rep1, class _Period, class _Rep2> 48104eeddc0SDimitry Andric inline _LIBCPP_INLINE_VISIBILITY 48204eeddc0SDimitry Andric _LIBCPP_CONSTEXPR 48304eeddc0SDimitry Andric typename enable_if 48404eeddc0SDimitry Andric < 48504eeddc0SDimitry Andric is_convertible<_Rep1, typename common_type<_Rep1, _Rep2>::type>::value, 48604eeddc0SDimitry Andric duration<typename common_type<_Rep1, _Rep2>::type, _Period> 48704eeddc0SDimitry Andric >::type 48804eeddc0SDimitry Andric operator*(const _Rep1& __s, const duration<_Rep2, _Period>& __d) 48904eeddc0SDimitry Andric { 49004eeddc0SDimitry Andric return __d * __s; 49104eeddc0SDimitry Andric } 49204eeddc0SDimitry Andric 49304eeddc0SDimitry Andric // Duration / 49404eeddc0SDimitry Andric 49504eeddc0SDimitry Andric template <class _Rep1, class _Period, class _Rep2> 49604eeddc0SDimitry Andric inline _LIBCPP_INLINE_VISIBILITY 49704eeddc0SDimitry Andric _LIBCPP_CONSTEXPR 49804eeddc0SDimitry Andric typename enable_if 49904eeddc0SDimitry Andric < 50004eeddc0SDimitry Andric !__is_duration<_Rep2>::value && 50104eeddc0SDimitry Andric is_convertible<_Rep2, typename common_type<_Rep1, _Rep2>::type>::value, 50204eeddc0SDimitry Andric duration<typename common_type<_Rep1, _Rep2>::type, _Period> 50304eeddc0SDimitry Andric >::type 50404eeddc0SDimitry Andric operator/(const duration<_Rep1, _Period>& __d, const _Rep2& __s) 50504eeddc0SDimitry Andric { 50604eeddc0SDimitry Andric typedef typename common_type<_Rep1, _Rep2>::type _Cr; 50704eeddc0SDimitry Andric typedef duration<_Cr, _Period> _Cd; 50804eeddc0SDimitry Andric return _Cd(_Cd(__d).count() / static_cast<_Cr>(__s)); 50904eeddc0SDimitry Andric } 51004eeddc0SDimitry Andric 51104eeddc0SDimitry Andric template <class _Rep1, class _Period1, class _Rep2, class _Period2> 51204eeddc0SDimitry Andric inline _LIBCPP_INLINE_VISIBILITY 51304eeddc0SDimitry Andric _LIBCPP_CONSTEXPR 51404eeddc0SDimitry Andric typename common_type<_Rep1, _Rep2>::type 51504eeddc0SDimitry Andric operator/(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) 51604eeddc0SDimitry Andric { 51704eeddc0SDimitry Andric typedef typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type _Ct; 51804eeddc0SDimitry Andric return _Ct(__lhs).count() / _Ct(__rhs).count(); 51904eeddc0SDimitry Andric } 52004eeddc0SDimitry Andric 52104eeddc0SDimitry Andric // Duration % 52204eeddc0SDimitry Andric 52304eeddc0SDimitry Andric template <class _Rep1, class _Period, class _Rep2> 52404eeddc0SDimitry Andric inline _LIBCPP_INLINE_VISIBILITY 52504eeddc0SDimitry Andric _LIBCPP_CONSTEXPR 52604eeddc0SDimitry Andric typename enable_if 52704eeddc0SDimitry Andric < 52804eeddc0SDimitry Andric !__is_duration<_Rep2>::value && 52904eeddc0SDimitry Andric is_convertible<_Rep2, typename common_type<_Rep1, _Rep2>::type>::value, 53004eeddc0SDimitry Andric duration<typename common_type<_Rep1, _Rep2>::type, _Period> 53104eeddc0SDimitry Andric >::type 53204eeddc0SDimitry Andric operator%(const duration<_Rep1, _Period>& __d, const _Rep2& __s) 53304eeddc0SDimitry Andric { 53404eeddc0SDimitry Andric typedef typename common_type<_Rep1, _Rep2>::type _Cr; 53504eeddc0SDimitry Andric typedef duration<_Cr, _Period> _Cd; 53604eeddc0SDimitry Andric return _Cd(_Cd(__d).count() % static_cast<_Cr>(__s)); 53704eeddc0SDimitry Andric } 53804eeddc0SDimitry Andric 53904eeddc0SDimitry Andric template <class _Rep1, class _Period1, class _Rep2, class _Period2> 54004eeddc0SDimitry Andric inline _LIBCPP_INLINE_VISIBILITY 54104eeddc0SDimitry Andric _LIBCPP_CONSTEXPR 54204eeddc0SDimitry Andric typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type 54304eeddc0SDimitry Andric operator%(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) 54404eeddc0SDimitry Andric { 54504eeddc0SDimitry Andric typedef typename common_type<_Rep1, _Rep2>::type _Cr; 54604eeddc0SDimitry Andric typedef typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type _Cd; 54704eeddc0SDimitry Andric return _Cd(static_cast<_Cr>(_Cd(__lhs).count()) % static_cast<_Cr>(_Cd(__rhs).count())); 54804eeddc0SDimitry Andric } 54904eeddc0SDimitry Andric 55004eeddc0SDimitry Andric } // namespace chrono 55104eeddc0SDimitry Andric 552*06c3fb27SDimitry Andric #if _LIBCPP_STD_VER >= 14 55304eeddc0SDimitry Andric // Suffixes for duration literals [time.duration.literals] 55404eeddc0SDimitry Andric inline namespace literals 55504eeddc0SDimitry Andric { 55604eeddc0SDimitry Andric inline namespace chrono_literals 55704eeddc0SDimitry Andric { 55804eeddc0SDimitry Andric 559bdd1243dSDimitry Andric _LIBCPP_HIDE_FROM_ABI constexpr chrono::hours operator""h(unsigned long long __h) 56004eeddc0SDimitry Andric { 56104eeddc0SDimitry Andric return chrono::hours(static_cast<chrono::hours::rep>(__h)); 56204eeddc0SDimitry Andric } 56304eeddc0SDimitry Andric 564bdd1243dSDimitry Andric _LIBCPP_HIDE_FROM_ABI constexpr chrono::duration<long double, ratio<3600,1>> operator""h(long double __h) 56504eeddc0SDimitry Andric { 56604eeddc0SDimitry Andric return chrono::duration<long double, ratio<3600,1>>(__h); 56704eeddc0SDimitry Andric } 56804eeddc0SDimitry Andric 56904eeddc0SDimitry Andric 570bdd1243dSDimitry Andric _LIBCPP_HIDE_FROM_ABI constexpr chrono::minutes operator""min(unsigned long long __m) 57104eeddc0SDimitry Andric { 57204eeddc0SDimitry Andric return chrono::minutes(static_cast<chrono::minutes::rep>(__m)); 57304eeddc0SDimitry Andric } 57404eeddc0SDimitry Andric 575bdd1243dSDimitry Andric _LIBCPP_HIDE_FROM_ABI constexpr chrono::duration<long double, ratio<60,1>> operator""min(long double __m) 57604eeddc0SDimitry Andric { 57704eeddc0SDimitry Andric return chrono::duration<long double, ratio<60,1>> (__m); 57804eeddc0SDimitry Andric } 57904eeddc0SDimitry Andric 58004eeddc0SDimitry Andric 581bdd1243dSDimitry Andric _LIBCPP_HIDE_FROM_ABI constexpr chrono::seconds operator""s(unsigned long long __s) 58204eeddc0SDimitry Andric { 58304eeddc0SDimitry Andric return chrono::seconds(static_cast<chrono::seconds::rep>(__s)); 58404eeddc0SDimitry Andric } 58504eeddc0SDimitry Andric 586bdd1243dSDimitry Andric _LIBCPP_HIDE_FROM_ABI constexpr chrono::duration<long double> operator""s(long double __s) 58704eeddc0SDimitry Andric { 58804eeddc0SDimitry Andric return chrono::duration<long double> (__s); 58904eeddc0SDimitry Andric } 59004eeddc0SDimitry Andric 59104eeddc0SDimitry Andric 592bdd1243dSDimitry Andric _LIBCPP_HIDE_FROM_ABI constexpr chrono::milliseconds operator""ms(unsigned long long __ms) 59304eeddc0SDimitry Andric { 59404eeddc0SDimitry Andric return chrono::milliseconds(static_cast<chrono::milliseconds::rep>(__ms)); 59504eeddc0SDimitry Andric } 59604eeddc0SDimitry Andric 597bdd1243dSDimitry Andric _LIBCPP_HIDE_FROM_ABI constexpr chrono::duration<long double, milli> operator""ms(long double __ms) 59804eeddc0SDimitry Andric { 59904eeddc0SDimitry Andric return chrono::duration<long double, milli>(__ms); 60004eeddc0SDimitry Andric } 60104eeddc0SDimitry Andric 60204eeddc0SDimitry Andric 603bdd1243dSDimitry Andric _LIBCPP_HIDE_FROM_ABI constexpr chrono::microseconds operator""us(unsigned long long __us) 60404eeddc0SDimitry Andric { 60504eeddc0SDimitry Andric return chrono::microseconds(static_cast<chrono::microseconds::rep>(__us)); 60604eeddc0SDimitry Andric } 60704eeddc0SDimitry Andric 608bdd1243dSDimitry Andric _LIBCPP_HIDE_FROM_ABI constexpr chrono::duration<long double, micro> operator""us(long double __us) 60904eeddc0SDimitry Andric { 61004eeddc0SDimitry Andric return chrono::duration<long double, micro> (__us); 61104eeddc0SDimitry Andric } 61204eeddc0SDimitry Andric 61304eeddc0SDimitry Andric 614bdd1243dSDimitry Andric _LIBCPP_HIDE_FROM_ABI constexpr chrono::nanoseconds operator""ns(unsigned long long __ns) 61504eeddc0SDimitry Andric { 61604eeddc0SDimitry Andric return chrono::nanoseconds(static_cast<chrono::nanoseconds::rep>(__ns)); 61704eeddc0SDimitry Andric } 61804eeddc0SDimitry Andric 619bdd1243dSDimitry Andric _LIBCPP_HIDE_FROM_ABI constexpr chrono::duration<long double, nano> operator""ns(long double __ns) 62004eeddc0SDimitry Andric { 62104eeddc0SDimitry Andric return chrono::duration<long double, nano> (__ns); 62204eeddc0SDimitry Andric } 62304eeddc0SDimitry Andric 62404eeddc0SDimitry Andric } // namespace chrono_literals 62504eeddc0SDimitry Andric } // namespace literals 62604eeddc0SDimitry Andric 62704eeddc0SDimitry Andric namespace chrono { // hoist the literals into namespace std::chrono 62804eeddc0SDimitry Andric using namespace literals::chrono_literals; 62904eeddc0SDimitry Andric } // namespace chrono 63004eeddc0SDimitry Andric 631*06c3fb27SDimitry Andric #endif // _LIBCPP_STD_VER >= 14 63204eeddc0SDimitry Andric 63304eeddc0SDimitry Andric _LIBCPP_END_NAMESPACE_STD 63404eeddc0SDimitry Andric 63504eeddc0SDimitry Andric _LIBCPP_POP_MACROS 63604eeddc0SDimitry Andric 637bdd1243dSDimitry Andric #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 638bdd1243dSDimitry Andric # include <type_traits> 639bdd1243dSDimitry Andric #endif 640bdd1243dSDimitry Andric 64104eeddc0SDimitry Andric #endif // _LIBCPP___CHRONO_DURATION_H 642