Path: blob/main/contrib/llvm-project/libcxx/include/__chrono/duration.h
35262 views
// -*- C++ -*-1//===----------------------------------------------------------------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//89#ifndef _LIBCPP___CHRONO_DURATION_H10#define _LIBCPP___CHRONO_DURATION_H1112#include <__compare/ordering.h>13#include <__compare/three_way_comparable.h>14#include <__config>15#include <__type_traits/common_type.h>16#include <__type_traits/enable_if.h>17#include <__type_traits/is_convertible.h>18#include <__type_traits/is_floating_point.h>19#include <limits>20#include <ratio>2122#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)23# pragma GCC system_header24#endif2526_LIBCPP_PUSH_MACROS27#include <__undef_macros>2829_LIBCPP_BEGIN_NAMESPACE_STD3031namespace chrono {3233template <class _Rep, class _Period = ratio<1> >34class _LIBCPP_TEMPLATE_VIS duration;3536template <class _Tp>37struct __is_duration : false_type {};3839template <class _Rep, class _Period>40struct __is_duration<duration<_Rep, _Period> > : true_type {};4142template <class _Rep, class _Period>43struct __is_duration<const duration<_Rep, _Period> > : true_type {};4445template <class _Rep, class _Period>46struct __is_duration<volatile duration<_Rep, _Period> > : true_type {};4748template <class _Rep, class _Period>49struct __is_duration<const volatile duration<_Rep, _Period> > : true_type {};5051} // namespace chrono5253template <class _Rep1, class _Period1, class _Rep2, class _Period2>54struct _LIBCPP_TEMPLATE_VIS common_type<chrono::duration<_Rep1, _Period1>, chrono::duration<_Rep2, _Period2> > {55typedef chrono::duration<typename common_type<_Rep1, _Rep2>::type, typename __ratio_gcd<_Period1, _Period2>::type>56type;57};5859namespace chrono {6061// duration_cast6263template <class _FromDuration,64class _ToDuration,65class _Period = typename ratio_divide<typename _FromDuration::period, typename _ToDuration::period>::type,66bool = _Period::num == 1,67bool = _Period::den == 1>68struct __duration_cast;6970template <class _FromDuration, class _ToDuration, class _Period>71struct __duration_cast<_FromDuration, _ToDuration, _Period, true, true> {72_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _ToDuration operator()(const _FromDuration& __fd) const {73return _ToDuration(static_cast<typename _ToDuration::rep>(__fd.count()));74}75};7677template <class _FromDuration, class _ToDuration, class _Period>78struct __duration_cast<_FromDuration, _ToDuration, _Period, true, false> {79_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _ToDuration operator()(const _FromDuration& __fd) const {80typedef typename common_type<typename _ToDuration::rep, typename _FromDuration::rep, intmax_t>::type _Ct;81return _ToDuration(82static_cast<typename _ToDuration::rep>(static_cast<_Ct>(__fd.count()) / static_cast<_Ct>(_Period::den)));83}84};8586template <class _FromDuration, class _ToDuration, class _Period>87struct __duration_cast<_FromDuration, _ToDuration, _Period, false, true> {88_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _ToDuration operator()(const _FromDuration& __fd) const {89typedef typename common_type<typename _ToDuration::rep, typename _FromDuration::rep, intmax_t>::type _Ct;90return _ToDuration(91static_cast<typename _ToDuration::rep>(static_cast<_Ct>(__fd.count()) * static_cast<_Ct>(_Period::num)));92}93};9495template <class _FromDuration, class _ToDuration, class _Period>96struct __duration_cast<_FromDuration, _ToDuration, _Period, false, false> {97_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _ToDuration operator()(const _FromDuration& __fd) const {98typedef typename common_type<typename _ToDuration::rep, typename _FromDuration::rep, intmax_t>::type _Ct;99return _ToDuration(static_cast<typename _ToDuration::rep>(100static_cast<_Ct>(__fd.count()) * static_cast<_Ct>(_Period::num) / static_cast<_Ct>(_Period::den)));101}102};103104template <class _ToDuration, class _Rep, class _Period, __enable_if_t<__is_duration<_ToDuration>::value, int> = 0>105inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _ToDuration duration_cast(const duration<_Rep, _Period>& __fd) {106return __duration_cast<duration<_Rep, _Period>, _ToDuration>()(__fd);107}108109template <class _Rep>110struct _LIBCPP_TEMPLATE_VIS treat_as_floating_point : is_floating_point<_Rep> {};111112#if _LIBCPP_STD_VER >= 17113template <class _Rep>114inline constexpr bool treat_as_floating_point_v = treat_as_floating_point<_Rep>::value;115#endif116117template <class _Rep>118struct _LIBCPP_TEMPLATE_VIS duration_values {119public:120_LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR _Rep zero() _NOEXCEPT { return _Rep(0); }121_LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR _Rep max() _NOEXCEPT { return numeric_limits<_Rep>::max(); }122_LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR _Rep min() _NOEXCEPT { return numeric_limits<_Rep>::lowest(); }123};124125#if _LIBCPP_STD_VER >= 17126template <class _ToDuration, class _Rep, class _Period, enable_if_t<__is_duration<_ToDuration>::value, int> = 0>127inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _ToDuration floor(const duration<_Rep, _Period>& __d) {128_ToDuration __t = chrono::duration_cast<_ToDuration>(__d);129if (__t > __d)130__t = __t - _ToDuration{1};131return __t;132}133134template <class _ToDuration, class _Rep, class _Period, enable_if_t<__is_duration<_ToDuration>::value, int> = 0>135inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _ToDuration ceil(const duration<_Rep, _Period>& __d) {136_ToDuration __t = chrono::duration_cast<_ToDuration>(__d);137if (__t < __d)138__t = __t + _ToDuration{1};139return __t;140}141142template <class _ToDuration, class _Rep, class _Period, enable_if_t<__is_duration<_ToDuration>::value, int> = 0>143inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _ToDuration round(const duration<_Rep, _Period>& __d) {144_ToDuration __lower = chrono::floor<_ToDuration>(__d);145_ToDuration __upper = __lower + _ToDuration{1};146auto __lower_diff = __d - __lower;147auto __upper_diff = __upper - __d;148if (__lower_diff < __upper_diff)149return __lower;150if (__lower_diff > __upper_diff)151return __upper;152return __lower.count() & 1 ? __upper : __lower;153}154#endif155156// duration157158template <class _Rep, class _Period>159class _LIBCPP_TEMPLATE_VIS duration {160static_assert(!__is_duration<_Rep>::value, "A duration representation can not be a duration");161static_assert(__is_ratio<_Period>::value, "Second template parameter of duration must be a std::ratio");162static_assert(_Period::num > 0, "duration period must be positive");163164template <class _R1, class _R2>165struct __no_overflow {166private:167static const intmax_t __gcd_n1_n2 = __static_gcd<_R1::num, _R2::num>::value;168static const intmax_t __gcd_d1_d2 = __static_gcd<_R1::den, _R2::den>::value;169static const intmax_t __n1 = _R1::num / __gcd_n1_n2;170static const intmax_t __d1 = _R1::den / __gcd_d1_d2;171static const intmax_t __n2 = _R2::num / __gcd_n1_n2;172static const intmax_t __d2 = _R2::den / __gcd_d1_d2;173static const intmax_t max = -((intmax_t(1) << (sizeof(intmax_t) * CHAR_BIT - 1)) + 1);174175template <intmax_t _Xp, intmax_t _Yp, bool __overflow>176struct __mul // __overflow == false177{178static const intmax_t value = _Xp * _Yp;179};180181template <intmax_t _Xp, intmax_t _Yp>182struct __mul<_Xp, _Yp, true> {183static const intmax_t value = 1;184};185186public:187static const bool value = (__n1 <= max / __d2) && (__n2 <= max / __d1);188typedef ratio<__mul<__n1, __d2, !value>::value, __mul<__n2, __d1, !value>::value> type;189};190191public:192typedef _Rep rep;193typedef typename _Period::type period;194195private:196rep __rep_;197198public:199#ifndef _LIBCPP_CXX03_LANG200constexpr duration() = default;201#else202_LIBCPP_HIDE_FROM_ABI duration() {}203#endif204205template <class _Rep2,206__enable_if_t<is_convertible<const _Rep2&, rep>::value &&207(treat_as_floating_point<rep>::value || !treat_as_floating_point<_Rep2>::value),208int> = 0>209_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit duration(const _Rep2& __r) : __rep_(__r) {}210211// conversions212template <class _Rep2,213class _Period2,214__enable_if_t<__no_overflow<_Period2, period>::value && (treat_as_floating_point<rep>::value ||215(__no_overflow<_Period2, period>::type::den == 1 &&216!treat_as_floating_point<_Rep2>::value)),217int> = 0>218_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR duration(const duration<_Rep2, _Period2>& __d)219: __rep_(chrono::duration_cast<duration>(__d).count()) {}220221// observer222223_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR rep count() const { return __rep_; }224225// arithmetic226227_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR typename common_type<duration>::type operator+() const {228return typename common_type<duration>::type(*this);229}230_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR typename common_type<duration>::type operator-() const {231return typename common_type<duration>::type(-__rep_);232}233_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 duration& operator++() {234++__rep_;235return *this;236}237_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 duration operator++(int) { return duration(__rep_++); }238_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 duration& operator--() {239--__rep_;240return *this;241}242_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 duration operator--(int) { return duration(__rep_--); }243244_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 duration& operator+=(const duration& __d) {245__rep_ += __d.count();246return *this;247}248_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 duration& operator-=(const duration& __d) {249__rep_ -= __d.count();250return *this;251}252253_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 duration& operator*=(const rep& __rhs) {254__rep_ *= __rhs;255return *this;256}257_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 duration& operator/=(const rep& __rhs) {258__rep_ /= __rhs;259return *this;260}261_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 duration& operator%=(const rep& __rhs) {262__rep_ %= __rhs;263return *this;264}265_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 duration& operator%=(const duration& __rhs) {266__rep_ %= __rhs.count();267return *this;268}269270// special values271272_LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR duration zero() _NOEXCEPT {273return duration(duration_values<rep>::zero());274}275_LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR duration min() _NOEXCEPT {276return duration(duration_values<rep>::min());277}278_LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR duration max() _NOEXCEPT {279return duration(duration_values<rep>::max());280}281};282283typedef duration<long long, nano> nanoseconds;284typedef duration<long long, micro> microseconds;285typedef duration<long long, milli> milliseconds;286typedef duration<long long > seconds;287typedef duration< long, ratio< 60> > minutes;288typedef duration< long, ratio<3600> > hours;289#if _LIBCPP_STD_VER >= 20290typedef duration< int, ratio_multiply<ratio<24>, hours::period>> days;291typedef duration< int, ratio_multiply<ratio<7>, days::period>> weeks;292typedef duration< int, ratio_multiply<ratio<146097, 400>, days::period>> years;293typedef duration< int, ratio_divide<years::period, ratio<12>>> months;294#endif295// Duration ==296297template <class _LhsDuration, class _RhsDuration>298struct __duration_eq {299_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator()(const _LhsDuration& __lhs, const _RhsDuration& __rhs) const {300typedef typename common_type<_LhsDuration, _RhsDuration>::type _Ct;301return _Ct(__lhs).count() == _Ct(__rhs).count();302}303};304305template <class _LhsDuration>306struct __duration_eq<_LhsDuration, _LhsDuration> {307_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator()(const _LhsDuration& __lhs, const _LhsDuration& __rhs) const {308return __lhs.count() == __rhs.count();309}310};311312template <class _Rep1, class _Period1, class _Rep2, class _Period2>313inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool314operator==(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) {315return __duration_eq<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >()(__lhs, __rhs);316}317318#if _LIBCPP_STD_VER <= 17319320// Duration !=321322template <class _Rep1, class _Period1, class _Rep2, class _Period2>323inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool324operator!=(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) {325return !(__lhs == __rhs);326}327328#endif // _LIBCPP_STD_VER <= 17329330// Duration <331332template <class _LhsDuration, class _RhsDuration>333struct __duration_lt {334_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator()(const _LhsDuration& __lhs, const _RhsDuration& __rhs) const {335typedef typename common_type<_LhsDuration, _RhsDuration>::type _Ct;336return _Ct(__lhs).count() < _Ct(__rhs).count();337}338};339340template <class _LhsDuration>341struct __duration_lt<_LhsDuration, _LhsDuration> {342_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator()(const _LhsDuration& __lhs, const _LhsDuration& __rhs) const {343return __lhs.count() < __rhs.count();344}345};346347template <class _Rep1, class _Period1, class _Rep2, class _Period2>348inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool349operator<(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) {350return __duration_lt<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >()(__lhs, __rhs);351}352353// Duration >354355template <class _Rep1, class _Period1, class _Rep2, class _Period2>356inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool357operator>(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) {358return __rhs < __lhs;359}360361// Duration <=362363template <class _Rep1, class _Period1, class _Rep2, class _Period2>364inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool365operator<=(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) {366return !(__rhs < __lhs);367}368369// Duration >=370371template <class _Rep1, class _Period1, class _Rep2, class _Period2>372inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool373operator>=(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) {374return !(__lhs < __rhs);375}376377#if _LIBCPP_STD_VER >= 20378379template <class _Rep1, class _Period1, class _Rep2, class _Period2>380requires three_way_comparable<common_type_t<_Rep1, _Rep2>>381_LIBCPP_HIDE_FROM_ABI constexpr auto382operator<=>(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) {383using _Ct = common_type_t<duration<_Rep1, _Period1>, duration<_Rep2, _Period2>>;384return _Ct(__lhs).count() <=> _Ct(__rhs).count();385}386387#endif // _LIBCPP_STD_VER >= 20388389// Duration +390391template <class _Rep1, class _Period1, class _Rep2, class _Period2>392inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR393typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type394operator+(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) {395typedef typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type _Cd;396return _Cd(_Cd(__lhs).count() + _Cd(__rhs).count());397}398399// Duration -400401template <class _Rep1, class _Period1, class _Rep2, class _Period2>402inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR403typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type404operator-(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) {405typedef typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type _Cd;406return _Cd(_Cd(__lhs).count() - _Cd(__rhs).count());407}408409// Duration *410411template <class _Rep1,412class _Period,413class _Rep2,414__enable_if_t<is_convertible<const _Rep2&, typename common_type<_Rep1, _Rep2>::type>::value, int> = 0>415inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR duration<typename common_type<_Rep1, _Rep2>::type, _Period>416operator*(const duration<_Rep1, _Period>& __d, const _Rep2& __s) {417typedef typename common_type<_Rep1, _Rep2>::type _Cr;418typedef duration<_Cr, _Period> _Cd;419return _Cd(_Cd(__d).count() * static_cast<_Cr>(__s));420}421422template <class _Rep1,423class _Period,424class _Rep2,425__enable_if_t<is_convertible<const _Rep1&, typename common_type<_Rep1, _Rep2>::type>::value, int> = 0>426inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR duration<typename common_type<_Rep1, _Rep2>::type, _Period>427operator*(const _Rep1& __s, const duration<_Rep2, _Period>& __d) {428return __d * __s;429}430431// Duration /432433template <class _Rep1,434class _Period,435class _Rep2,436__enable_if_t<!__is_duration<_Rep2>::value &&437is_convertible<const _Rep2&, typename common_type<_Rep1, _Rep2>::type>::value,438int> = 0>439inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR duration<typename common_type<_Rep1, _Rep2>::type, _Period>440operator/(const duration<_Rep1, _Period>& __d, const _Rep2& __s) {441typedef typename common_type<_Rep1, _Rep2>::type _Cr;442typedef duration<_Cr, _Period> _Cd;443return _Cd(_Cd(__d).count() / static_cast<_Cr>(__s));444}445446template <class _Rep1, class _Period1, class _Rep2, class _Period2>447inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR typename common_type<_Rep1, _Rep2>::type448operator/(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) {449typedef typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type _Ct;450return _Ct(__lhs).count() / _Ct(__rhs).count();451}452453// Duration %454455template <class _Rep1,456class _Period,457class _Rep2,458__enable_if_t<!__is_duration<_Rep2>::value &&459is_convertible<const _Rep2&, typename common_type<_Rep1, _Rep2>::type>::value,460int> = 0>461inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR duration<typename common_type<_Rep1, _Rep2>::type, _Period>462operator%(const duration<_Rep1, _Period>& __d, const _Rep2& __s) {463typedef typename common_type<_Rep1, _Rep2>::type _Cr;464typedef duration<_Cr, _Period> _Cd;465return _Cd(_Cd(__d).count() % static_cast<_Cr>(__s));466}467468template <class _Rep1, class _Period1, class _Rep2, class _Period2>469inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR470typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type471operator%(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) {472typedef typename common_type<_Rep1, _Rep2>::type _Cr;473typedef typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type _Cd;474return _Cd(static_cast<_Cr>(_Cd(__lhs).count()) % static_cast<_Cr>(_Cd(__rhs).count()));475}476477} // namespace chrono478479#if _LIBCPP_STD_VER >= 14480// Suffixes for duration literals [time.duration.literals]481inline namespace literals {482inline namespace chrono_literals {483484_LIBCPP_HIDE_FROM_ABI constexpr chrono::hours operator""h(unsigned long long __h) {485return chrono::hours(static_cast<chrono::hours::rep>(__h));486}487488_LIBCPP_HIDE_FROM_ABI constexpr chrono::duration<long double, ratio<3600, 1>> operator""h(long double __h) {489return chrono::duration<long double, ratio<3600, 1>>(__h);490}491492_LIBCPP_HIDE_FROM_ABI constexpr chrono::minutes operator""min(unsigned long long __m) {493return chrono::minutes(static_cast<chrono::minutes::rep>(__m));494}495496_LIBCPP_HIDE_FROM_ABI constexpr chrono::duration<long double, ratio<60, 1>> operator""min(long double __m) {497return chrono::duration<long double, ratio<60, 1>>(__m);498}499500_LIBCPP_HIDE_FROM_ABI constexpr chrono::seconds operator""s(unsigned long long __s) {501return chrono::seconds(static_cast<chrono::seconds::rep>(__s));502}503504_LIBCPP_HIDE_FROM_ABI constexpr chrono::duration<long double> operator""s(long double __s) {505return chrono::duration<long double>(__s);506}507508_LIBCPP_HIDE_FROM_ABI constexpr chrono::milliseconds operator""ms(unsigned long long __ms) {509return chrono::milliseconds(static_cast<chrono::milliseconds::rep>(__ms));510}511512_LIBCPP_HIDE_FROM_ABI constexpr chrono::duration<long double, milli> operator""ms(long double __ms) {513return chrono::duration<long double, milli>(__ms);514}515516_LIBCPP_HIDE_FROM_ABI constexpr chrono::microseconds operator""us(unsigned long long __us) {517return chrono::microseconds(static_cast<chrono::microseconds::rep>(__us));518}519520_LIBCPP_HIDE_FROM_ABI constexpr chrono::duration<long double, micro> operator""us(long double __us) {521return chrono::duration<long double, micro>(__us);522}523524_LIBCPP_HIDE_FROM_ABI constexpr chrono::nanoseconds operator""ns(unsigned long long __ns) {525return chrono::nanoseconds(static_cast<chrono::nanoseconds::rep>(__ns));526}527528_LIBCPP_HIDE_FROM_ABI constexpr chrono::duration<long double, nano> operator""ns(long double __ns) {529return chrono::duration<long double, nano>(__ns);530}531532} // namespace chrono_literals533} // namespace literals534535namespace chrono { // hoist the literals into namespace std::chrono536using namespace literals::chrono_literals;537} // namespace chrono538539#endif // _LIBCPP_STD_VER >= 14540541_LIBCPP_END_NAMESPACE_STD542543_LIBCPP_POP_MACROS544545#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20546# include <type_traits>547#endif548549#endif // _LIBCPP___CHRONO_DURATION_H550551552