// -*- C++ -*- //===---------------------------- chrono ----------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// #ifndef _LIBCPP_CHRONO #define _LIBCPP_CHRONO /* chrono synopsis namespace std { namespace chrono { template constexpr ToDuration duration_cast(const duration& fd); template struct treat_as_floating_point : is_floating_point {}; template struct duration_values { public: static constexpr Rep zero(); static constexpr Rep max(); static constexpr Rep min(); }; // duration template > class duration { static_assert(!__is_duration::value, "A duration representation can not be a duration"); static_assert(__is_ratio::value, "Second template parameter of duration must be a std::ratio"); static_assert(Period::num > 0, "duration period must be positive"); public: typedef Rep rep; typedef Period period; constexpr duration() = default; template constexpr explicit duration(const Rep2& r, typename enable_if < is_convertible::value && (treat_as_floating_point::value || !treat_as_floating_point::value && !treat_as_floating_point::value) >::type* = 0); // conversions template constexpr duration(const duration& d, typename enable_if < treat_as_floating_point::value || ratio_divide::type::den == 1 >::type* = 0); // observer constexpr rep count() const; // arithmetic constexpr duration operator+() const; constexpr duration operator-() const; duration& operator++(); duration operator++(int); duration& operator--(); duration operator--(int); duration& operator+=(const duration& d); duration& operator-=(const duration& d); duration& operator*=(const rep& rhs); duration& operator/=(const rep& rhs); // special values static constexpr duration zero(); static constexpr duration min(); static constexpr duration max(); }; typedef duration nanoseconds; typedef duration microseconds; typedef duration milliseconds; typedef duration seconds; typedef duration< long, ratio< 60> > minutes; typedef duration< long, ratio<3600> > hours; template class time_point { public: typedef Clock clock; typedef Duration duration; typedef typename duration::rep rep; typedef typename duration::period period; private: duration d_; // exposition only public: time_point(); // has value "epoch" // constexpr in C++14 explicit time_point(const duration& d); // same as time_point() + d // constexpr in C++14 // conversions template time_point(const time_point& t); // constexpr in C++14 // observer duration time_since_epoch() const; // constexpr in C++14 // arithmetic time_point& operator+=(const duration& d); time_point& operator-=(const duration& d); // special values static constexpr time_point min(); static constexpr time_point max(); }; } // chrono // common_type traits template struct common_type, chrono::duration>; template struct common_type, chrono::time_point>; namespace chrono { // duration arithmetic template constexpr typename common_type, duration>::type operator+(const duration& lhs, const duration& rhs); template constexpr typename common_type, duration>::type operator-(const duration& lhs, const duration& rhs); template constexpr duration::type, Period> operator*(const duration& d, const Rep2& s); template constexpr duration::type, Period> operator*(const Rep1& s, const duration& d); template constexpr duration::type, Period> operator/(const duration& d, const Rep2& s); template constexpr typename common_type::type operator/(const duration& lhs, const duration& rhs); // duration comparisons template constexpr bool operator==(const duration& lhs, const duration& rhs); template constexpr bool operator!=(const duration& lhs, const duration& rhs); template constexpr bool operator< (const duration& lhs, const duration& rhs); template constexpr bool operator<=(const duration& lhs, const duration& rhs); template constexpr bool operator> (const duration& lhs, const duration& rhs); template constexpr bool operator>=(const duration& lhs, const duration& rhs); // duration_cast template ToDuration duration_cast(const duration& d); // time_point arithmetic (all constexpr in C++14) template time_point>::type> operator+(const time_point& lhs, const duration& rhs); template time_point, Duration2>::type> operator+(const duration& lhs, const time_point& rhs); template time_point>::type> operator-(const time_point& lhs, const duration& rhs); template typename common_type::type operator-(const time_point& lhs, const time_point& rhs); // time_point comparisons (all constexpr in C++14) template bool operator==(const time_point& lhs, const time_point& rhs); template bool operator!=(const time_point& lhs, const time_point& rhs); template bool operator< (const time_point& lhs, const time_point& rhs); template bool operator<=(const time_point& lhs, const time_point& rhs); template bool operator> (const time_point& lhs, const time_point& rhs); template bool operator>=(const time_point& lhs, const time_point& rhs); // time_point_cast (constexpr in C++14) template time_point time_point_cast(const time_point& t); // Clocks class system_clock { public: typedef microseconds duration; typedef duration::rep rep; typedef duration::period period; typedef chrono::time_point time_point; static const bool is_steady = false; // constexpr in C++14 static time_point now() noexcept; static time_t to_time_t (const time_point& __t) noexcept; static time_point from_time_t(time_t __t) noexcept; }; class steady_clock { public: typedef nanoseconds duration; typedef duration::rep rep; typedef duration::period period; typedef chrono::time_point time_point; static const bool is_steady = true; // constexpr in C++14 static time_point now() noexcept; }; typedef steady_clock high_resolution_clock; } // chrono constexpr chrono::hours operator "" h(unsigned long long); // C++14 constexpr chrono::duration> operator "" h(long double); // C++14 constexpr chrono::minutes operator "" min(unsigned long long); // C++14 constexpr chrono::duration> operator "" min(long double); // C++14 constexpr chrono::seconds operator "" s(unsigned long long); // C++14 constexpr chrono::duration operator "" s(long double); // C++14 constexpr chrono::milliseconds operator "" ms(unsigned long long); // C++14 constexpr chrono::duration operator "" ms(long double); // C++14 constexpr chrono::microseconds operator "" us(unsigned long long); // C++14 constexpr chrono::duration operator "" us(long double); // C++14 constexpr chrono::nanoseconds operator "" ns(unsigned long long); // C++14 constexpr chrono::duration operator "" ns(long double); // C++14 } // std */ #include <__config> #include #include #include #include #include <__undef_min_max> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif _LIBCPP_BEGIN_NAMESPACE_STD namespace chrono { template > class _LIBCPP_TYPE_VIS duration; template struct __is_duration : false_type {}; template struct __is_duration > : true_type {}; template struct __is_duration > : true_type {}; template struct __is_duration > : true_type {}; template struct __is_duration > : true_type {}; } // chrono template struct _LIBCPP_TYPE_VIS common_type, chrono::duration<_Rep2, _Period2> > { typedef chrono::duration::type, typename __ratio_gcd<_Period1, _Period2>::type> type; }; namespace chrono { // duration_cast template ::type, bool = _Period::num == 1, bool = _Period::den == 1> struct __duration_cast; template struct __duration_cast<_FromDuration, _ToDuration, _Period, true, true> { _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR _ToDuration operator()(const _FromDuration& __fd) const { return _ToDuration(static_cast(__fd.count())); } }; template struct __duration_cast<_FromDuration, _ToDuration, _Period, true, false> { _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR _ToDuration operator()(const _FromDuration& __fd) const { typedef typename common_type::type _Ct; return _ToDuration(static_cast( static_cast<_Ct>(__fd.count()) / static_cast<_Ct>(_Period::den))); } }; template struct __duration_cast<_FromDuration, _ToDuration, _Period, false, true> { _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR _ToDuration operator()(const _FromDuration& __fd) const { typedef typename common_type::type _Ct; return _ToDuration(static_cast( static_cast<_Ct>(__fd.count()) * static_cast<_Ct>(_Period::num))); } }; template struct __duration_cast<_FromDuration, _ToDuration, _Period, false, false> { _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR _ToDuration operator()(const _FromDuration& __fd) const { typedef typename common_type::type _Ct; return _ToDuration(static_cast( static_cast<_Ct>(__fd.count()) * static_cast<_Ct>(_Period::num) / static_cast<_Ct>(_Period::den))); } }; template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR typename enable_if < __is_duration<_ToDuration>::value, _ToDuration >::type duration_cast(const duration<_Rep, _Period>& __fd) { return __duration_cast, _ToDuration>()(__fd); } template struct _LIBCPP_TYPE_VIS treat_as_floating_point : is_floating_point<_Rep> {}; template struct _LIBCPP_TYPE_VIS duration_values { public: _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR _Rep zero() {return _Rep(0);} _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR _Rep max() {return numeric_limits<_Rep>::max();} _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR _Rep min() {return numeric_limits<_Rep>::lowest();} }; // duration template class _LIBCPP_TYPE_VIS duration { static_assert(!__is_duration<_Rep>::value, "A duration representation can not be a duration"); static_assert(__is_ratio<_Period>::value, "Second template parameter of duration must be a std::ratio"); static_assert(_Period::num > 0, "duration period must be positive"); public: typedef _Rep rep; typedef _Period period; private: rep __rep_; public: _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR #ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS duration() = default; #else duration() {} #endif template _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR explicit duration(const _Rep2& __r, typename enable_if < is_convertible<_Rep2, rep>::value && (treat_as_floating_point::value || !treat_as_floating_point<_Rep2>::value) >::type* = 0) : __rep_(__r) {} // conversions template _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR duration(const duration<_Rep2, _Period2>& __d, typename enable_if < treat_as_floating_point::value || (ratio_divide<_Period2, period>::type::den == 1 && !treat_as_floating_point<_Rep2>::value) >::type* = 0) : __rep_(_VSTD::chrono::duration_cast(__d).count()) {} // observer _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR rep count() const {return __rep_;} // arithmetic _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR duration operator+() const {return *this;} _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR duration operator-() const {return duration(-__rep_);} _LIBCPP_INLINE_VISIBILITY duration& operator++() {++__rep_; return *this;} _LIBCPP_INLINE_VISIBILITY duration operator++(int) {return duration(__rep_++);} _LIBCPP_INLINE_VISIBILITY duration& operator--() {--__rep_; return *this;} _LIBCPP_INLINE_VISIBILITY duration operator--(int) {return duration(__rep_--);} _LIBCPP_INLINE_VISIBILITY duration& operator+=(const duration& __d) {__rep_ += __d.count(); return *this;} _LIBCPP_INLINE_VISIBILITY duration& operator-=(const duration& __d) {__rep_ -= __d.count(); return *this;} _LIBCPP_INLINE_VISIBILITY duration& operator*=(const rep& rhs) {__rep_ *= rhs; return *this;} _LIBCPP_INLINE_VISIBILITY duration& operator/=(const rep& rhs) {__rep_ /= rhs; return *this;} _LIBCPP_INLINE_VISIBILITY duration& operator%=(const rep& rhs) {__rep_ %= rhs; return *this;} _LIBCPP_INLINE_VISIBILITY duration& operator%=(const duration& rhs) {__rep_ %= rhs.count(); return *this;} // special values _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR duration zero() {return duration(duration_values::zero());} _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR duration min() {return duration(duration_values::min());} _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR duration max() {return duration(duration_values::max());} }; typedef duration nanoseconds; typedef duration microseconds; typedef duration milliseconds; typedef duration seconds; typedef duration< long, ratio< 60> > minutes; typedef duration< long, ratio<3600> > hours; // Duration == template struct __duration_eq { _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR bool operator()(const _LhsDuration& __lhs, const _RhsDuration& __rhs) const { typedef typename common_type<_LhsDuration, _RhsDuration>::type _Ct; return _Ct(__lhs).count() == _Ct(__rhs).count(); } }; template struct __duration_eq<_LhsDuration, _LhsDuration> { _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR bool operator()(const _LhsDuration& __lhs, const _LhsDuration& __rhs) const {return __lhs.count() == __rhs.count();} }; template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR bool operator==(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) { return __duration_eq, duration<_Rep2, _Period2> >()(__lhs, __rhs); } // Duration != template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR bool operator!=(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) { return !(__lhs == __rhs); } // Duration < template struct __duration_lt { _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR bool operator()(const _LhsDuration& __lhs, const _RhsDuration& __rhs) const { typedef typename common_type<_LhsDuration, _RhsDuration>::type _Ct; return _Ct(__lhs).count() < _Ct(__rhs).count(); } }; template struct __duration_lt<_LhsDuration, _LhsDuration> { _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR bool operator()(const _LhsDuration& __lhs, const _LhsDuration& __rhs) const {return __lhs.count() < __rhs.count();} }; template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR bool operator< (const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) { return __duration_lt, duration<_Rep2, _Period2> >()(__lhs, __rhs); } // Duration > template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR bool operator> (const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) { return __rhs < __lhs; } // Duration <= template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR bool operator<=(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) { return !(__rhs < __lhs); } // Duration >= template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR bool operator>=(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) { return !(__lhs < __rhs); } // Duration + template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR typename common_type, duration<_Rep2, _Period2> >::type operator+(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) { typedef typename common_type, duration<_Rep2, _Period2> >::type _Cd; return _Cd(_Cd(__lhs).count() + _Cd(__rhs).count()); } // Duration - template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR typename common_type, duration<_Rep2, _Period2> >::type operator-(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) { typedef typename common_type, duration<_Rep2, _Period2> >::type _Cd; return _Cd(_Cd(__lhs).count() - _Cd(__rhs).count()); } // Duration * template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR typename enable_if < is_convertible<_Rep2, typename common_type<_Rep1, _Rep2>::type>::value, duration::type, _Period> >::type operator*(const duration<_Rep1, _Period>& __d, const _Rep2& __s) { typedef typename common_type<_Rep1, _Rep2>::type _Cr; typedef duration<_Cr, _Period> _Cd; return _Cd(_Cd(__d).count() * static_cast<_Cr>(__s)); } template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR typename enable_if < is_convertible<_Rep1, typename common_type<_Rep1, _Rep2>::type>::value, duration::type, _Period> >::type operator*(const _Rep1& __s, const duration<_Rep2, _Period>& __d) { return __d * __s; } // Duration / template ::value> struct __duration_divide_result { }; template ::type>::value> struct __duration_divide_imp { }; template struct __duration_divide_imp, _Rep2, true> { typedef duration::type, _Period> type; }; template struct __duration_divide_result, _Rep2, false> : __duration_divide_imp, _Rep2> { }; template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR typename __duration_divide_result, _Rep2>::type operator/(const duration<_Rep1, _Period>& __d, const _Rep2& __s) { typedef typename common_type<_Rep1, _Rep2>::type _Cr; typedef duration<_Cr, _Period> _Cd; return _Cd(_Cd(__d).count() / static_cast<_Cr>(__s)); } template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR typename common_type<_Rep1, _Rep2>::type operator/(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) { typedef typename common_type, duration<_Rep2, _Period2> >::type _Ct; return _Ct(__lhs).count() / _Ct(__rhs).count(); } // Duration % template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR typename __duration_divide_result, _Rep2>::type operator%(const duration<_Rep1, _Period>& __d, const _Rep2& __s) { typedef typename common_type<_Rep1, _Rep2>::type _Cr; typedef duration<_Cr, _Period> _Cd; return _Cd(_Cd(__d).count() % static_cast<_Cr>(__s)); } template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR typename common_type, duration<_Rep2, _Period2> >::type operator%(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) { typedef typename common_type<_Rep1, _Rep2>::type _Cr; typedef typename common_type, duration<_Rep2, _Period2> >::type _Cd; return _Cd(static_cast<_Cr>(_Cd(__lhs).count()) % static_cast<_Cr>(_Cd(__rhs).count())); } ////////////////////////////////////////////////////////// ///////////////////// time_point ///////////////////////// ////////////////////////////////////////////////////////// template class _LIBCPP_TYPE_VIS time_point { static_assert(__is_duration<_Duration>::value, "Second template parameter of time_point must be a std::chrono::duration"); public: typedef _Clock clock; typedef _Duration duration; typedef typename duration::rep rep; typedef typename duration::period period; private: duration __d_; public: _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 time_point() : __d_(duration::zero()) {} _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 explicit time_point(const duration& __d) : __d_(__d) {} // conversions template _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 time_point(const time_point& t, typename enable_if < is_convertible<_Duration2, duration>::value >::type* = 0) : __d_(t.time_since_epoch()) {} // observer _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 duration time_since_epoch() const {return __d_;} // arithmetic _LIBCPP_INLINE_VISIBILITY time_point& operator+=(const duration& __d) {__d_ += __d; return *this;} _LIBCPP_INLINE_VISIBILITY time_point& operator-=(const duration& __d) {__d_ -= __d; return *this;} // special values _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR time_point min() {return time_point(duration::min());} _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR time_point max() {return time_point(duration::max());} }; } // chrono template struct _LIBCPP_TYPE_VIS common_type, chrono::time_point<_Clock, _Duration2> > { typedef chrono::time_point<_Clock, typename common_type<_Duration1, _Duration2>::type> type; }; namespace chrono { template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 time_point<_Clock, _ToDuration> time_point_cast(const time_point<_Clock, _Duration>& __t) { return time_point<_Clock, _ToDuration>(_VSTD::chrono::duration_cast<_ToDuration>(__t.time_since_epoch())); } // time_point == template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 bool operator==(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs) { return __lhs.time_since_epoch() == __rhs.time_since_epoch(); } // time_point != template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 bool operator!=(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs) { return !(__lhs == __rhs); } // time_point < template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 bool operator<(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs) { return __lhs.time_since_epoch() < __rhs.time_since_epoch(); } // time_point > template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 bool operator>(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs) { return __rhs < __lhs; } // time_point <= template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 bool operator<=(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs) { return !(__rhs < __lhs); } // time_point >= template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 bool operator>=(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs) { return !(__lhs < __rhs); } // time_point operator+(time_point x, duration y); template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 time_point<_Clock, typename common_type<_Duration1, duration<_Rep2, _Period2> >::type> operator+(const time_point<_Clock, _Duration1>& __lhs, const duration<_Rep2, _Period2>& __rhs) { typedef time_point<_Clock, typename common_type<_Duration1, duration<_Rep2, _Period2> >::type> _Tr; return _Tr (__lhs.time_since_epoch() + __rhs); } // time_point operator+(duration x, time_point y); template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 time_point<_Clock, typename common_type, _Duration2>::type> operator+(const duration<_Rep1, _Period1>& __lhs, const time_point<_Clock, _Duration2>& __rhs) { return __rhs + __lhs; } // time_point operator-(time_point x, duration y); template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 time_point<_Clock, typename common_type<_Duration1, duration<_Rep2, _Period2> >::type> operator-(const time_point<_Clock, _Duration1>& __lhs, const duration<_Rep2, _Period2>& __rhs) { return __lhs + (-__rhs); } // duration operator-(time_point x, time_point y); template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 typename common_type<_Duration1, _Duration2>::type operator-(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs) { return __lhs.time_since_epoch() - __rhs.time_since_epoch(); } ////////////////////////////////////////////////////////// /////////////////////// clocks /////////////////////////// ////////////////////////////////////////////////////////// class _LIBCPP_TYPE_VIS system_clock { public: typedef microseconds duration; typedef duration::rep rep; typedef duration::period period; typedef chrono::time_point time_point; static _LIBCPP_CONSTEXPR_AFTER_CXX11 const bool is_steady = false; static time_point now() _NOEXCEPT; static time_t to_time_t (const time_point& __t) _NOEXCEPT; static time_point from_time_t(time_t __t) _NOEXCEPT; }; class _LIBCPP_TYPE_VIS steady_clock { public: typedef nanoseconds duration; typedef duration::rep rep; typedef duration::period period; typedef chrono::time_point time_point; static _LIBCPP_CONSTEXPR_AFTER_CXX11 const bool is_steady = true; static time_point now() _NOEXCEPT; }; typedef steady_clock high_resolution_clock; } // chrono #if _LIBCPP_STD_VER > 11 // Literal suffixes for chrono types // inline // Deviation from N3690. // We believe the inline to be a defect and have submitted an LWG issue. // An LWG issue number has not yet been assigned. namespace literals { inline namespace chrono_literals { constexpr chrono::hours operator"" h(unsigned long long __h) { return chrono::hours(static_cast(__h)); } constexpr chrono::duration> operator"" h(long double __h) { return chrono::duration>(__h); } constexpr chrono::minutes operator"" min(unsigned long long __m) { return chrono::minutes(static_cast(__m)); } constexpr chrono::duration> operator"" min(long double __m) { return chrono::duration> (__m); } constexpr chrono::seconds operator"" s(unsigned long long __s) { return chrono::seconds(static_cast(__s)); } constexpr chrono::duration operator"" s(long double __s) { return chrono::duration (__s); } constexpr chrono::milliseconds operator"" ms(unsigned long long __ms) { return chrono::milliseconds(static_cast(__ms)); } constexpr chrono::duration operator"" ms(long double __ms) { return chrono::duration(__ms); } constexpr chrono::microseconds operator"" us(unsigned long long __us) { return chrono::microseconds(static_cast(__us)); } constexpr chrono::duration operator"" us(long double __us) { return chrono::duration (__us); } constexpr chrono::nanoseconds operator"" ns(unsigned long long __ns) { return chrono::nanoseconds(static_cast(__ns)); } constexpr chrono::duration operator"" ns(long double __ns) { return chrono::duration (__ns); } }} #endif _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP_CHRONO