2 //===----------------------------------------------------------------------===//
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
8 //===----------------------------------------------------------------------===//
10 #ifndef _LIBCPP___CHRONO_DURATION_H
11 #define _LIBCPP___CHRONO_DURATION_H
16 #include <type_traits>
18 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19 #pragma GCC system_header
23 #include <__undef_macros>
25 _LIBCPP_BEGIN_NAMESPACE_STD
30 template <class _Rep
, class _Period
= ratio
<1> > class _LIBCPP_TEMPLATE_VIS duration
;
33 struct __is_duration
: false_type
{};
35 template <class _Rep
, class _Period
>
36 struct __is_duration
<duration
<_Rep
, _Period
> > : true_type
{};
38 template <class _Rep
, class _Period
>
39 struct __is_duration
<const duration
<_Rep
, _Period
> > : true_type
{};
41 template <class _Rep
, class _Period
>
42 struct __is_duration
<volatile duration
<_Rep
, _Period
> > : true_type
{};
44 template <class _Rep
, class _Period
>
45 struct __is_duration
<const volatile duration
<_Rep
, _Period
> > : true_type
{};
49 template <class _Rep1
, class _Period1
, class _Rep2
, class _Period2
>
50 struct _LIBCPP_TEMPLATE_VIS common_type
<chrono::duration
<_Rep1
, _Period1
>,
51 chrono::duration
<_Rep2
, _Period2
> >
53 typedef chrono::duration
<typename common_type
<_Rep1
, _Rep2
>::type
,
54 typename __ratio_gcd
<_Period1
, _Period2
>::type
> type
;
61 template <class _FromDuration
, class _ToDuration
,
62 class _Period
= typename ratio_divide
<typename
_FromDuration::period
, typename
_ToDuration::period
>::type
,
63 bool = _Period::num
== 1,
64 bool = _Period::den
== 1>
65 struct __duration_cast
;
67 template <class _FromDuration
, class _ToDuration
, class _Period
>
68 struct __duration_cast
<_FromDuration
, _ToDuration
, _Period
, true, true>
70 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
71 _ToDuration
operator()(const _FromDuration
& __fd
) const
73 return _ToDuration(static_cast<typename
_ToDuration::rep
>(__fd
.count()));
77 template <class _FromDuration
, class _ToDuration
, class _Period
>
78 struct __duration_cast
<_FromDuration
, _ToDuration
, _Period
, true, false>
80 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
81 _ToDuration
operator()(const _FromDuration
& __fd
) const
83 typedef typename common_type
<typename
_ToDuration::rep
, typename
_FromDuration::rep
, intmax_t>::type _Ct
;
84 return _ToDuration(static_cast<typename
_ToDuration::rep
>(
85 static_cast<_Ct
>(__fd
.count()) / static_cast<_Ct
>(_Period::den
)));
89 template <class _FromDuration
, class _ToDuration
, class _Period
>
90 struct __duration_cast
<_FromDuration
, _ToDuration
, _Period
, false, true>
92 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
93 _ToDuration
operator()(const _FromDuration
& __fd
) const
95 typedef typename common_type
<typename
_ToDuration::rep
, typename
_FromDuration::rep
, intmax_t>::type _Ct
;
96 return _ToDuration(static_cast<typename
_ToDuration::rep
>(
97 static_cast<_Ct
>(__fd
.count()) * static_cast<_Ct
>(_Period::num
)));
101 template <class _FromDuration
, class _ToDuration
, class _Period
>
102 struct __duration_cast
<_FromDuration
, _ToDuration
, _Period
, false, false>
104 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
105 _ToDuration
operator()(const _FromDuration
& __fd
) const
107 typedef typename common_type
<typename
_ToDuration::rep
, typename
_FromDuration::rep
, intmax_t>::type _Ct
;
108 return _ToDuration(static_cast<typename
_ToDuration::rep
>(
109 static_cast<_Ct
>(__fd
.count()) * static_cast<_Ct
>(_Period::num
)
110 / static_cast<_Ct
>(_Period::den
)));
114 template <class _ToDuration
, class _Rep
, class _Period
>
115 inline _LIBCPP_INLINE_VISIBILITY
119 __is_duration
<_ToDuration
>::value
,
122 duration_cast(const duration
<_Rep
, _Period
>& __fd
)
124 return __duration_cast
<duration
<_Rep
, _Period
>, _ToDuration
>()(__fd
);
127 template <class _Rep
>
128 struct _LIBCPP_TEMPLATE_VIS treat_as_floating_point
: is_floating_point
<_Rep
> {};
130 #if _LIBCPP_STD_VER > 14
131 template <class _Rep
>
132 inline constexpr bool treat_as_floating_point_v
= treat_as_floating_point
<_Rep
>::value
;
135 template <class _Rep
>
136 struct _LIBCPP_TEMPLATE_VIS duration_values
139 _LIBCPP_INLINE_VISIBILITY
static _LIBCPP_CONSTEXPR _Rep
zero() _NOEXCEPT
{return _Rep(0);}
140 _LIBCPP_INLINE_VISIBILITY
static _LIBCPP_CONSTEXPR _Rep
max() _NOEXCEPT
{return numeric_limits
<_Rep
>::max();}
141 _LIBCPP_INLINE_VISIBILITY
static _LIBCPP_CONSTEXPR _Rep
min() _NOEXCEPT
{return numeric_limits
<_Rep
>::lowest();}
144 #if _LIBCPP_STD_VER > 14
145 template <class _ToDuration
, class _Rep
, class _Period
>
146 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
149 __is_duration
<_ToDuration
>::value
,
152 floor(const duration
<_Rep
, _Period
>& __d
)
154 _ToDuration __t
= duration_cast
<_ToDuration
>(__d
);
156 __t
= __t
- _ToDuration
{1};
160 template <class _ToDuration
, class _Rep
, class _Period
>
161 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
164 __is_duration
<_ToDuration
>::value
,
167 ceil(const duration
<_Rep
, _Period
>& __d
)
169 _ToDuration __t
= duration_cast
<_ToDuration
>(__d
);
171 __t
= __t
+ _ToDuration
{1};
175 template <class _ToDuration
, class _Rep
, class _Period
>
176 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
179 __is_duration
<_ToDuration
>::value
,
182 round(const duration
<_Rep
, _Period
>& __d
)
184 _ToDuration __lower
= floor
<_ToDuration
>(__d
);
185 _ToDuration __upper
= __lower
+ _ToDuration
{1};
186 auto __lowerDiff
= __d
- __lower
;
187 auto __upperDiff
= __upper
- __d
;
188 if (__lowerDiff
< __upperDiff
)
190 if (__lowerDiff
> __upperDiff
)
192 return __lower
.count() & 1 ? __upper
: __lower
;
198 template <class _Rep
, class _Period
>
199 class _LIBCPP_TEMPLATE_VIS duration
201 static_assert(!__is_duration
<_Rep
>::value
, "A duration representation can not be a duration");
202 static_assert(__is_ratio
<_Period
>::value
, "Second template parameter of duration must be a std::ratio");
203 static_assert(_Period::num
> 0, "duration period must be positive");
205 template <class _R1
, class _R2
>
209 static const intmax_t __gcd_n1_n2
= __static_gcd
<_R1::num
, _R2::num
>::value
;
210 static const intmax_t __gcd_d1_d2
= __static_gcd
<_R1::den
, _R2::den
>::value
;
211 static const intmax_t __n1
= _R1::num
/ __gcd_n1_n2
;
212 static const intmax_t __d1
= _R1::den
/ __gcd_d1_d2
;
213 static const intmax_t __n2
= _R2::num
/ __gcd_n1_n2
;
214 static const intmax_t __d2
= _R2::den
/ __gcd_d1_d2
;
215 static const intmax_t max
= -((intmax_t(1) << (sizeof(intmax_t) * CHAR_BIT
- 1)) + 1);
217 template <intmax_t _Xp
, intmax_t _Yp
, bool __overflow
>
218 struct __mul
// __overflow == false
220 static const intmax_t value
= _Xp
* _Yp
;
223 template <intmax_t _Xp
, intmax_t _Yp
>
224 struct __mul
<_Xp
, _Yp
, true>
226 static const intmax_t value
= 1;
230 static const bool value
= (__n1
<= max
/ __d2
) && (__n2
<= max
/ __d1
);
231 typedef ratio
<__mul
<__n1
, __d2
, !value
>::value
,
232 __mul
<__n2
, __d1
, !value
>::value
> type
;
237 typedef typename
_Period::type period
;
242 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
243 #ifndef _LIBCPP_CXX03_LANG
244 duration() = default;
249 template <class _Rep2
>
250 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
251 explicit duration(const _Rep2
& __r
,
254 is_convertible
<_Rep2
, rep
>::value
&&
255 (treat_as_floating_point
<rep
>::value
||
256 !treat_as_floating_point
<_Rep2
>::value
)
261 template <class _Rep2
, class _Period2
>
262 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
263 duration(const duration
<_Rep2
, _Period2
>& __d
,
266 __no_overflow
<_Period2
, period
>::value
&& (
267 treat_as_floating_point
<rep
>::value
||
268 (__no_overflow
<_Period2
, period
>::type::den
== 1 &&
269 !treat_as_floating_point
<_Rep2
>::value
))
271 : __rep_(chrono::duration_cast
<duration
>(__d
).count()) {}
275 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR rep
count() const {return __rep_
;}
279 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR typename common_type
<duration
>::type
operator+() const {return typename common_type
<duration
>::type(*this);}
280 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR typename common_type
<duration
>::type
operator-() const {return typename common_type
<duration
>::type(-__rep_
);}
281 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration
& operator++() {++__rep_
; return *this;}
282 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration
operator++(int) {return duration(__rep_
++);}
283 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration
& operator--() {--__rep_
; return *this;}
284 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration
operator--(int) {return duration(__rep_
--);}
286 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration
& operator+=(const duration
& __d
) {__rep_
+= __d
.count(); return *this;}
287 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration
& operator-=(const duration
& __d
) {__rep_
-= __d
.count(); return *this;}
289 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration
& operator*=(const rep
& rhs
) {__rep_
*= rhs
; return *this;}
290 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration
& operator/=(const rep
& rhs
) {__rep_
/= rhs
; return *this;}
291 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration
& operator%=(const rep
& rhs
) {__rep_
%= rhs
; return *this;}
292 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration
& operator%=(const duration
& rhs
) {__rep_
%= rhs
.count(); return *this;}
296 _LIBCPP_INLINE_VISIBILITY
static _LIBCPP_CONSTEXPR duration
zero() _NOEXCEPT
{return duration(duration_values
<rep
>::zero());}
297 _LIBCPP_INLINE_VISIBILITY
static _LIBCPP_CONSTEXPR duration
min() _NOEXCEPT
{return duration(duration_values
<rep
>::min());}
298 _LIBCPP_INLINE_VISIBILITY
static _LIBCPP_CONSTEXPR duration
max() _NOEXCEPT
{return duration(duration_values
<rep
>::max());}
301 typedef duration
<long long, nano
> nanoseconds
;
302 typedef duration
<long long, micro
> microseconds
;
303 typedef duration
<long long, milli
> milliseconds
;
304 typedef duration
<long long > seconds
;
305 typedef duration
< long, ratio
< 60> > minutes
;
306 typedef duration
< long, ratio
<3600> > hours
;
307 #if _LIBCPP_STD_VER > 17
308 typedef duration
< int, ratio_multiply
<ratio
<24>, hours::period
>> days
;
309 typedef duration
< int, ratio_multiply
<ratio
<7>, days::period
>> weeks
;
310 typedef duration
< int, ratio_multiply
<ratio
<146097, 400>, days::period
>> years
;
311 typedef duration
< int, ratio_divide
<years::period
, ratio
<12>>> months
;
315 template <class _LhsDuration
, class _RhsDuration
>
318 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
319 bool operator()(const _LhsDuration
& __lhs
, const _RhsDuration
& __rhs
) const
321 typedef typename common_type
<_LhsDuration
, _RhsDuration
>::type _Ct
;
322 return _Ct(__lhs
).count() == _Ct(__rhs
).count();
326 template <class _LhsDuration
>
327 struct __duration_eq
<_LhsDuration
, _LhsDuration
>
329 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
330 bool operator()(const _LhsDuration
& __lhs
, const _LhsDuration
& __rhs
) const
331 {return __lhs
.count() == __rhs
.count();}
334 template <class _Rep1
, class _Period1
, class _Rep2
, class _Period2
>
335 inline _LIBCPP_INLINE_VISIBILITY
338 operator==(const duration
<_Rep1
, _Period1
>& __lhs
, const duration
<_Rep2
, _Period2
>& __rhs
)
340 return __duration_eq
<duration
<_Rep1
, _Period1
>, duration
<_Rep2
, _Period2
> >()(__lhs
, __rhs
);
345 template <class _Rep1
, class _Period1
, class _Rep2
, class _Period2
>
346 inline _LIBCPP_INLINE_VISIBILITY
349 operator!=(const duration
<_Rep1
, _Period1
>& __lhs
, const duration
<_Rep2
, _Period2
>& __rhs
)
351 return !(__lhs
== __rhs
);
356 template <class _LhsDuration
, class _RhsDuration
>
359 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
360 bool operator()(const _LhsDuration
& __lhs
, const _RhsDuration
& __rhs
) const
362 typedef typename common_type
<_LhsDuration
, _RhsDuration
>::type _Ct
;
363 return _Ct(__lhs
).count() < _Ct(__rhs
).count();
367 template <class _LhsDuration
>
368 struct __duration_lt
<_LhsDuration
, _LhsDuration
>
370 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
371 bool operator()(const _LhsDuration
& __lhs
, const _LhsDuration
& __rhs
) const
372 {return __lhs
.count() < __rhs
.count();}
375 template <class _Rep1
, class _Period1
, class _Rep2
, class _Period2
>
376 inline _LIBCPP_INLINE_VISIBILITY
379 operator< (const duration
<_Rep1
, _Period1
>& __lhs
, const duration
<_Rep2
, _Period2
>& __rhs
)
381 return __duration_lt
<duration
<_Rep1
, _Period1
>, duration
<_Rep2
, _Period2
> >()(__lhs
, __rhs
);
386 template <class _Rep1
, class _Period1
, class _Rep2
, class _Period2
>
387 inline _LIBCPP_INLINE_VISIBILITY
390 operator> (const duration
<_Rep1
, _Period1
>& __lhs
, const duration
<_Rep2
, _Period2
>& __rhs
)
392 return __rhs
< __lhs
;
397 template <class _Rep1
, class _Period1
, class _Rep2
, class _Period2
>
398 inline _LIBCPP_INLINE_VISIBILITY
401 operator<=(const duration
<_Rep1
, _Period1
>& __lhs
, const duration
<_Rep2
, _Period2
>& __rhs
)
403 return !(__rhs
< __lhs
);
408 template <class _Rep1
, class _Period1
, class _Rep2
, class _Period2
>
409 inline _LIBCPP_INLINE_VISIBILITY
412 operator>=(const duration
<_Rep1
, _Period1
>& __lhs
, const duration
<_Rep2
, _Period2
>& __rhs
)
414 return !(__lhs
< __rhs
);
419 template <class _Rep1
, class _Period1
, class _Rep2
, class _Period2
>
420 inline _LIBCPP_INLINE_VISIBILITY
422 typename common_type
<duration
<_Rep1
, _Period1
>, duration
<_Rep2
, _Period2
> >::type
423 operator+(const duration
<_Rep1
, _Period1
>& __lhs
, const duration
<_Rep2
, _Period2
>& __rhs
)
425 typedef typename common_type
<duration
<_Rep1
, _Period1
>, duration
<_Rep2
, _Period2
> >::type _Cd
;
426 return _Cd(_Cd(__lhs
).count() + _Cd(__rhs
).count());
431 template <class _Rep1
, class _Period1
, class _Rep2
, class _Period2
>
432 inline _LIBCPP_INLINE_VISIBILITY
434 typename common_type
<duration
<_Rep1
, _Period1
>, duration
<_Rep2
, _Period2
> >::type
435 operator-(const duration
<_Rep1
, _Period1
>& __lhs
, const duration
<_Rep2
, _Period2
>& __rhs
)
437 typedef typename common_type
<duration
<_Rep1
, _Period1
>, duration
<_Rep2
, _Period2
> >::type _Cd
;
438 return _Cd(_Cd(__lhs
).count() - _Cd(__rhs
).count());
443 template <class _Rep1
, class _Period
, class _Rep2
>
444 inline _LIBCPP_INLINE_VISIBILITY
448 is_convertible
<_Rep2
, typename common_type
<_Rep1
, _Rep2
>::type
>::value
,
449 duration
<typename common_type
<_Rep1
, _Rep2
>::type
, _Period
>
451 operator*(const duration
<_Rep1
, _Period
>& __d
, const _Rep2
& __s
)
453 typedef typename common_type
<_Rep1
, _Rep2
>::type _Cr
;
454 typedef duration
<_Cr
, _Period
> _Cd
;
455 return _Cd(_Cd(__d
).count() * static_cast<_Cr
>(__s
));
458 template <class _Rep1
, class _Period
, class _Rep2
>
459 inline _LIBCPP_INLINE_VISIBILITY
463 is_convertible
<_Rep1
, typename common_type
<_Rep1
, _Rep2
>::type
>::value
,
464 duration
<typename common_type
<_Rep1
, _Rep2
>::type
, _Period
>
466 operator*(const _Rep1
& __s
, const duration
<_Rep2
, _Period
>& __d
)
473 template <class _Rep1
, class _Period
, class _Rep2
>
474 inline _LIBCPP_INLINE_VISIBILITY
478 !__is_duration
<_Rep2
>::value
&&
479 is_convertible
<_Rep2
, typename common_type
<_Rep1
, _Rep2
>::type
>::value
,
480 duration
<typename common_type
<_Rep1
, _Rep2
>::type
, _Period
>
482 operator/(const duration
<_Rep1
, _Period
>& __d
, const _Rep2
& __s
)
484 typedef typename common_type
<_Rep1
, _Rep2
>::type _Cr
;
485 typedef duration
<_Cr
, _Period
> _Cd
;
486 return _Cd(_Cd(__d
).count() / static_cast<_Cr
>(__s
));
489 template <class _Rep1
, class _Period1
, class _Rep2
, class _Period2
>
490 inline _LIBCPP_INLINE_VISIBILITY
492 typename common_type
<_Rep1
, _Rep2
>::type
493 operator/(const duration
<_Rep1
, _Period1
>& __lhs
, const duration
<_Rep2
, _Period2
>& __rhs
)
495 typedef typename common_type
<duration
<_Rep1
, _Period1
>, duration
<_Rep2
, _Period2
> >::type _Ct
;
496 return _Ct(__lhs
).count() / _Ct(__rhs
).count();
501 template <class _Rep1
, class _Period
, class _Rep2
>
502 inline _LIBCPP_INLINE_VISIBILITY
506 !__is_duration
<_Rep2
>::value
&&
507 is_convertible
<_Rep2
, typename common_type
<_Rep1
, _Rep2
>::type
>::value
,
508 duration
<typename common_type
<_Rep1
, _Rep2
>::type
, _Period
>
510 operator%(const duration
<_Rep1
, _Period
>& __d
, const _Rep2
& __s
)
512 typedef typename common_type
<_Rep1
, _Rep2
>::type _Cr
;
513 typedef duration
<_Cr
, _Period
> _Cd
;
514 return _Cd(_Cd(__d
).count() % static_cast<_Cr
>(__s
));
517 template <class _Rep1
, class _Period1
, class _Rep2
, class _Period2
>
518 inline _LIBCPP_INLINE_VISIBILITY
520 typename common_type
<duration
<_Rep1
, _Period1
>, duration
<_Rep2
, _Period2
> >::type
521 operator%(const duration
<_Rep1
, _Period1
>& __lhs
, const duration
<_Rep2
, _Period2
>& __rhs
)
523 typedef typename common_type
<_Rep1
, _Rep2
>::type _Cr
;
524 typedef typename common_type
<duration
<_Rep1
, _Period1
>, duration
<_Rep2
, _Period2
> >::type _Cd
;
525 return _Cd(static_cast<_Cr
>(_Cd(__lhs
).count()) % static_cast<_Cr
>(_Cd(__rhs
).count()));
528 } // namespace chrono
530 #if _LIBCPP_STD_VER > 11
531 // Suffixes for duration literals [time.duration.literals]
532 inline namespace literals
534 inline namespace chrono_literals
537 constexpr chrono::hours
operator""h(unsigned long long __h
)
539 return chrono::hours(static_cast<chrono::hours::rep
>(__h
));
542 constexpr chrono::duration
<long double, ratio
<3600,1>> operator""h(long double __h
)
544 return chrono::duration
<long double, ratio
<3600,1>>(__h
);
548 constexpr chrono::minutes
operator""min(unsigned long long __m
)
550 return chrono::minutes(static_cast<chrono::minutes::rep
>(__m
));
553 constexpr chrono::duration
<long double, ratio
<60,1>> operator""min(long double __m
)
555 return chrono::duration
<long double, ratio
<60,1>> (__m
);
559 constexpr chrono::seconds
operator""s(unsigned long long __s
)
561 return chrono::seconds(static_cast<chrono::seconds::rep
>(__s
));
564 constexpr chrono::duration
<long double> operator""s(long double __s
)
566 return chrono::duration
<long double> (__s
);
570 constexpr chrono::milliseconds
operator""ms(unsigned long long __ms
)
572 return chrono::milliseconds(static_cast<chrono::milliseconds::rep
>(__ms
));
575 constexpr chrono::duration
<long double, milli
> operator""ms(long double __ms
)
577 return chrono::duration
<long double, milli
>(__ms
);
581 constexpr chrono::microseconds
operator""us(unsigned long long __us
)
583 return chrono::microseconds(static_cast<chrono::microseconds::rep
>(__us
));
586 constexpr chrono::duration
<long double, micro
> operator""us(long double __us
)
588 return chrono::duration
<long double, micro
> (__us
);
592 constexpr chrono::nanoseconds
operator""ns(unsigned long long __ns
)
594 return chrono::nanoseconds(static_cast<chrono::nanoseconds::rep
>(__ns
));
597 constexpr chrono::duration
<long double, nano
> operator""ns(long double __ns
)
599 return chrono::duration
<long double, nano
> (__ns
);
602 } // namespace chrono_literals
603 } // namespace literals
605 namespace chrono
{ // hoist the literals into namespace std::chrono
606 using namespace literals::chrono_literals
;
607 } // namespace chrono
609 #endif // _LIBCPP_STD_VER > 11
611 _LIBCPP_END_NAMESPACE_STD
615 #endif // _LIBCPP___CHRONO_DURATION_H