Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / libcxx / include / __chrono / duration.h
blobe4e5f03b48bf321827acd1e3ac6a3f551d7cb4bd
1 // -*- C++ -*-
2 //===----------------------------------------------------------------------===//
3 //
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
7 //
8 //===----------------------------------------------------------------------===//
10 #ifndef _LIBCPP___CHRONO_DURATION_H
11 #define _LIBCPP___CHRONO_DURATION_H
13 #include <__compare/ordering.h>
14 #include <__compare/three_way_comparable.h>
15 #include <__config>
16 #include <__type_traits/common_type.h>
17 #include <__type_traits/enable_if.h>
18 #include <__type_traits/is_convertible.h>
19 #include <__type_traits/is_floating_point.h>
20 #include <limits>
21 #include <ratio>
23 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
24 # pragma GCC system_header
25 #endif
27 _LIBCPP_PUSH_MACROS
28 #include <__undef_macros>
30 _LIBCPP_BEGIN_NAMESPACE_STD
32 namespace chrono
35 template <class _Rep, class _Period = ratio<1> > class _LIBCPP_TEMPLATE_VIS duration;
37 template <class _Tp>
38 struct __is_duration : false_type {};
40 template <class _Rep, class _Period>
41 struct __is_duration<duration<_Rep, _Period> > : true_type {};
43 template <class _Rep, class _Period>
44 struct __is_duration<const duration<_Rep, _Period> > : true_type {};
46 template <class _Rep, class _Period>
47 struct __is_duration<volatile duration<_Rep, _Period> > : true_type {};
49 template <class _Rep, class _Period>
50 struct __is_duration<const volatile duration<_Rep, _Period> > : true_type {};
52 } // namespace chrono
54 template <class _Rep1, class _Period1, class _Rep2, class _Period2>
55 struct _LIBCPP_TEMPLATE_VIS common_type<chrono::duration<_Rep1, _Period1>,
56 chrono::duration<_Rep2, _Period2> >
58 typedef chrono::duration<typename common_type<_Rep1, _Rep2>::type,
59 typename __ratio_gcd<_Period1, _Period2>::type> type;
62 namespace chrono {
64 // duration_cast
66 template <class _FromDuration, class _ToDuration,
67 class _Period = typename ratio_divide<typename _FromDuration::period, typename _ToDuration::period>::type,
68 bool = _Period::num == 1,
69 bool = _Period::den == 1>
70 struct __duration_cast;
72 template <class _FromDuration, class _ToDuration, class _Period>
73 struct __duration_cast<_FromDuration, _ToDuration, _Period, true, true>
75 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
76 _ToDuration operator()(const _FromDuration& __fd) const
78 return _ToDuration(static_cast<typename _ToDuration::rep>(__fd.count()));
82 template <class _FromDuration, class _ToDuration, class _Period>
83 struct __duration_cast<_FromDuration, _ToDuration, _Period, true, false>
85 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
86 _ToDuration operator()(const _FromDuration& __fd) const
88 typedef typename common_type<typename _ToDuration::rep, typename _FromDuration::rep, intmax_t>::type _Ct;
89 return _ToDuration(static_cast<typename _ToDuration::rep>(
90 static_cast<_Ct>(__fd.count()) / static_cast<_Ct>(_Period::den)));
94 template <class _FromDuration, class _ToDuration, class _Period>
95 struct __duration_cast<_FromDuration, _ToDuration, _Period, false, true>
97 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
98 _ToDuration operator()(const _FromDuration& __fd) const
100 typedef typename common_type<typename _ToDuration::rep, typename _FromDuration::rep, intmax_t>::type _Ct;
101 return _ToDuration(static_cast<typename _ToDuration::rep>(
102 static_cast<_Ct>(__fd.count()) * static_cast<_Ct>(_Period::num)));
106 template <class _FromDuration, class _ToDuration, class _Period>
107 struct __duration_cast<_FromDuration, _ToDuration, _Period, false, false>
109 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
110 _ToDuration operator()(const _FromDuration& __fd) const
112 typedef typename common_type<typename _ToDuration::rep, typename _FromDuration::rep, intmax_t>::type _Ct;
113 return _ToDuration(static_cast<typename _ToDuration::rep>(
114 static_cast<_Ct>(__fd.count()) * static_cast<_Ct>(_Period::num)
115 / static_cast<_Ct>(_Period::den)));
119 template <class _ToDuration, class _Rep, class _Period, __enable_if_t<__is_duration<_ToDuration>::value, int> = 0>
120 inline _LIBCPP_INLINE_VISIBILITY
121 _LIBCPP_CONSTEXPR
122 _ToDuration
123 duration_cast(const duration<_Rep, _Period>& __fd)
125 return __duration_cast<duration<_Rep, _Period>, _ToDuration>()(__fd);
128 template <class _Rep>
129 struct _LIBCPP_TEMPLATE_VIS treat_as_floating_point : is_floating_point<_Rep> {};
131 #if _LIBCPP_STD_VER >= 17
132 template <class _Rep>
133 inline constexpr bool treat_as_floating_point_v = treat_as_floating_point<_Rep>::value;
134 #endif
136 template <class _Rep>
137 struct _LIBCPP_TEMPLATE_VIS duration_values
139 public:
140 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR _Rep zero() _NOEXCEPT {return _Rep(0);}
141 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR _Rep max() _NOEXCEPT {return numeric_limits<_Rep>::max();}
142 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR _Rep min() _NOEXCEPT {return numeric_limits<_Rep>::lowest();}
145 #if _LIBCPP_STD_VER >= 17
146 template <class _ToDuration, class _Rep, class _Period, enable_if_t<__is_duration<_ToDuration>::value, int> = 0>
147 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
148 _ToDuration
149 floor(const duration<_Rep, _Period>& __d)
151 _ToDuration __t = chrono::duration_cast<_ToDuration>(__d);
152 if (__t > __d)
153 __t = __t - _ToDuration{1};
154 return __t;
157 template <class _ToDuration, class _Rep, class _Period, enable_if_t<__is_duration<_ToDuration>::value, int> = 0>
158 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
159 _ToDuration
160 ceil(const duration<_Rep, _Period>& __d)
162 _ToDuration __t = chrono::duration_cast<_ToDuration>(__d);
163 if (__t < __d)
164 __t = __t + _ToDuration{1};
165 return __t;
168 template <class _ToDuration, class _Rep, class _Period, enable_if_t<__is_duration<_ToDuration>::value, int> = 0>
169 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
170 _ToDuration
171 round(const duration<_Rep, _Period>& __d)
173 _ToDuration __lower = chrono::floor<_ToDuration>(__d);
174 _ToDuration __upper = __lower + _ToDuration{1};
175 auto __lower_diff = __d - __lower;
176 auto __upper_diff = __upper - __d;
177 if (__lower_diff < __upper_diff)
178 return __lower;
179 if (__lower_diff > __upper_diff)
180 return __upper;
181 return __lower.count() & 1 ? __upper : __lower;
183 #endif
185 // duration
187 template <class _Rep, class _Period>
188 class _LIBCPP_TEMPLATE_VIS duration
190 static_assert(!__is_duration<_Rep>::value, "A duration representation can not be a duration");
191 static_assert(__is_ratio<_Period>::value, "Second template parameter of duration must be a std::ratio");
192 static_assert(_Period::num > 0, "duration period must be positive");
194 template <class _R1, class _R2>
195 struct __no_overflow
197 private:
198 static const intmax_t __gcd_n1_n2 = __static_gcd<_R1::num, _R2::num>::value;
199 static const intmax_t __gcd_d1_d2 = __static_gcd<_R1::den, _R2::den>::value;
200 static const intmax_t __n1 = _R1::num / __gcd_n1_n2;
201 static const intmax_t __d1 = _R1::den / __gcd_d1_d2;
202 static const intmax_t __n2 = _R2::num / __gcd_n1_n2;
203 static const intmax_t __d2 = _R2::den / __gcd_d1_d2;
204 static const intmax_t max = -((intmax_t(1) << (sizeof(intmax_t) * CHAR_BIT - 1)) + 1);
206 template <intmax_t _Xp, intmax_t _Yp, bool __overflow>
207 struct __mul // __overflow == false
209 static const intmax_t value = _Xp * _Yp;
212 template <intmax_t _Xp, intmax_t _Yp>
213 struct __mul<_Xp, _Yp, true>
215 static const intmax_t value = 1;
218 public:
219 static const bool value = (__n1 <= max / __d2) && (__n2 <= max / __d1);
220 typedef ratio<__mul<__n1, __d2, !value>::value,
221 __mul<__n2, __d1, !value>::value> type;
224 public:
225 typedef _Rep rep;
226 typedef typename _Period::type period;
227 private:
228 rep __rep_;
229 public:
231 #ifndef _LIBCPP_CXX03_LANG
232 constexpr duration() = default;
233 #else
234 _LIBCPP_HIDE_FROM_ABI duration() {}
235 #endif
237 template <class _Rep2, __enable_if_t<is_convertible<const _Rep2&, rep>::value &&
238 (treat_as_floating_point<rep>::value ||
239 !treat_as_floating_point<_Rep2>::value), int> = 0>
240 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
241 explicit duration(const _Rep2& __r)
242 : __rep_(__r) {}
244 // conversions
245 template <class _Rep2, class _Period2, __enable_if_t<__no_overflow<_Period2, period>::value && (
246 treat_as_floating_point<rep>::value ||
247 (__no_overflow<_Period2, period>::type::den == 1 &&
248 !treat_as_floating_point<_Rep2>::value)), int> = 0>
249 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
250 duration(const duration<_Rep2, _Period2>& __d)
251 : __rep_(chrono::duration_cast<duration>(__d).count()) {}
253 // observer
255 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR rep count() const {return __rep_;}
257 // arithmetic
259 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR typename common_type<duration>::type operator+() const {return typename common_type<duration>::type(*this);}
260 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR typename common_type<duration>::type operator-() const {return typename common_type<duration>::type(-__rep_);}
261 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17 duration& operator++() {++__rep_; return *this;}
262 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17 duration operator++(int) {return duration(__rep_++);}
263 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17 duration& operator--() {--__rep_; return *this;}
264 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17 duration operator--(int) {return duration(__rep_--);}
266 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17 duration& operator+=(const duration& __d) {__rep_ += __d.count(); return *this;}
267 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17 duration& operator-=(const duration& __d) {__rep_ -= __d.count(); return *this;}
269 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17 duration& operator*=(const rep& __rhs) {__rep_ *= __rhs; return *this;}
270 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17 duration& operator/=(const rep& __rhs) {__rep_ /= __rhs; return *this;}
271 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17 duration& operator%=(const rep& __rhs) {__rep_ %= __rhs; return *this;}
272 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17 duration& operator%=(const duration& __rhs) {__rep_ %= __rhs.count(); return *this;}
274 // special values
276 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR duration zero() _NOEXCEPT {return duration(duration_values<rep>::zero());}
277 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR duration min() _NOEXCEPT {return duration(duration_values<rep>::min());}
278 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR duration max() _NOEXCEPT {return duration(duration_values<rep>::max());}
281 typedef duration<long long, nano> nanoseconds;
282 typedef duration<long long, micro> microseconds;
283 typedef duration<long long, milli> milliseconds;
284 typedef duration<long long > seconds;
285 typedef duration< long, ratio< 60> > minutes;
286 typedef duration< long, ratio<3600> > hours;
287 #if _LIBCPP_STD_VER >= 20
288 typedef duration< int, ratio_multiply<ratio<24>, hours::period>> days;
289 typedef duration< int, ratio_multiply<ratio<7>, days::period>> weeks;
290 typedef duration< int, ratio_multiply<ratio<146097, 400>, days::period>> years;
291 typedef duration< int, ratio_divide<years::period, ratio<12>>> months;
292 #endif
293 // Duration ==
295 template <class _LhsDuration, class _RhsDuration>
296 struct __duration_eq
298 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
299 bool operator()(const _LhsDuration& __lhs, const _RhsDuration& __rhs) const
301 typedef typename common_type<_LhsDuration, _RhsDuration>::type _Ct;
302 return _Ct(__lhs).count() == _Ct(__rhs).count();
306 template <class _LhsDuration>
307 struct __duration_eq<_LhsDuration, _LhsDuration>
309 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
310 bool operator()(const _LhsDuration& __lhs, const _LhsDuration& __rhs) const
311 {return __lhs.count() == __rhs.count();}
314 template <class _Rep1, class _Period1, class _Rep2, class _Period2>
315 inline _LIBCPP_INLINE_VISIBILITY
316 _LIBCPP_CONSTEXPR
317 bool
318 operator==(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
320 return __duration_eq<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >()(__lhs, __rhs);
323 #if _LIBCPP_STD_VER <= 17
325 // Duration !=
327 template <class _Rep1, class _Period1, class _Rep2, class _Period2>
328 inline _LIBCPP_INLINE_VISIBILITY
329 _LIBCPP_CONSTEXPR
330 bool
331 operator!=(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
333 return !(__lhs == __rhs);
336 #endif // _LIBCPP_STD_VER <= 17
338 // Duration <
340 template <class _LhsDuration, class _RhsDuration>
341 struct __duration_lt
343 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
344 bool operator()(const _LhsDuration& __lhs, const _RhsDuration& __rhs) const
346 typedef typename common_type<_LhsDuration, _RhsDuration>::type _Ct;
347 return _Ct(__lhs).count() < _Ct(__rhs).count();
351 template <class _LhsDuration>
352 struct __duration_lt<_LhsDuration, _LhsDuration>
354 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
355 bool operator()(const _LhsDuration& __lhs, const _LhsDuration& __rhs) const
356 {return __lhs.count() < __rhs.count();}
359 template <class _Rep1, class _Period1, class _Rep2, class _Period2>
360 inline _LIBCPP_INLINE_VISIBILITY
361 _LIBCPP_CONSTEXPR
362 bool
363 operator< (const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
365 return __duration_lt<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >()(__lhs, __rhs);
368 // Duration >
370 template <class _Rep1, class _Period1, class _Rep2, class _Period2>
371 inline _LIBCPP_INLINE_VISIBILITY
372 _LIBCPP_CONSTEXPR
373 bool
374 operator> (const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
376 return __rhs < __lhs;
379 // Duration <=
381 template <class _Rep1, class _Period1, class _Rep2, class _Period2>
382 inline _LIBCPP_INLINE_VISIBILITY
383 _LIBCPP_CONSTEXPR
384 bool
385 operator<=(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
387 return !(__rhs < __lhs);
390 // Duration >=
392 template <class _Rep1, class _Period1, class _Rep2, class _Period2>
393 inline _LIBCPP_INLINE_VISIBILITY
394 _LIBCPP_CONSTEXPR
395 bool
396 operator>=(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
398 return !(__lhs < __rhs);
401 #if _LIBCPP_STD_VER >= 20
403 template<class _Rep1, class _Period1, class _Rep2, class _Period2>
404 requires three_way_comparable<common_type_t<_Rep1, _Rep2>>
405 _LIBCPP_HIDE_FROM_ABI
406 constexpr auto operator<=>(const duration<_Rep1, _Period1>& __lhs,
407 const duration<_Rep2, _Period2>& __rhs)
409 using _Ct = common_type_t<duration<_Rep1, _Period1>, duration<_Rep2, _Period2>>;
410 return _Ct(__lhs).count() <=> _Ct(__rhs).count();
413 #endif // _LIBCPP_STD_VER >= 20
415 // Duration +
417 template <class _Rep1, class _Period1, class _Rep2, class _Period2>
418 inline _LIBCPP_INLINE_VISIBILITY
419 _LIBCPP_CONSTEXPR
420 typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type
421 operator+(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
423 typedef typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type _Cd;
424 return _Cd(_Cd(__lhs).count() + _Cd(__rhs).count());
427 // Duration -
429 template <class _Rep1, class _Period1, class _Rep2, class _Period2>
430 inline _LIBCPP_INLINE_VISIBILITY
431 _LIBCPP_CONSTEXPR
432 typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type
433 operator-(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
435 typedef typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type _Cd;
436 return _Cd(_Cd(__lhs).count() - _Cd(__rhs).count());
439 // Duration *
441 template <class _Rep1, class _Period, class _Rep2,
442 __enable_if_t<is_convertible<_Rep2, typename common_type<_Rep1, _Rep2>::type>::value, int> = 0>
443 inline _LIBCPP_INLINE_VISIBILITY
444 _LIBCPP_CONSTEXPR
445 duration<typename common_type<_Rep1, _Rep2>::type, _Period>
446 operator*(const duration<_Rep1, _Period>& __d, const _Rep2& __s)
448 typedef typename common_type<_Rep1, _Rep2>::type _Cr;
449 typedef duration<_Cr, _Period> _Cd;
450 return _Cd(_Cd(__d).count() * static_cast<_Cr>(__s));
453 template <class _Rep1, class _Period, class _Rep2,
454 __enable_if_t<is_convertible<_Rep1, typename common_type<_Rep1, _Rep2>::type>::value, int> = 0>
455 inline _LIBCPP_INLINE_VISIBILITY
456 _LIBCPP_CONSTEXPR
457 duration<typename common_type<_Rep1, _Rep2>::type, _Period>
458 operator*(const _Rep1& __s, const duration<_Rep2, _Period>& __d)
460 return __d * __s;
463 // Duration /
465 template <class _Rep1, class _Period, class _Rep2,
466 __enable_if_t<!__is_duration<_Rep2>::value && is_convertible<_Rep2, typename common_type<_Rep1, _Rep2>::type>::value, int> = 0>
467 inline _LIBCPP_INLINE_VISIBILITY
468 _LIBCPP_CONSTEXPR
469 duration<typename common_type<_Rep1, _Rep2>::type, _Period>
470 operator/(const duration<_Rep1, _Period>& __d, const _Rep2& __s)
472 typedef typename common_type<_Rep1, _Rep2>::type _Cr;
473 typedef duration<_Cr, _Period> _Cd;
474 return _Cd(_Cd(__d).count() / static_cast<_Cr>(__s));
477 template <class _Rep1, class _Period1, class _Rep2, class _Period2>
478 inline _LIBCPP_INLINE_VISIBILITY
479 _LIBCPP_CONSTEXPR
480 typename common_type<_Rep1, _Rep2>::type
481 operator/(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
483 typedef typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type _Ct;
484 return _Ct(__lhs).count() / _Ct(__rhs).count();
487 // Duration %
489 template <class _Rep1, class _Period, class _Rep2,
490 __enable_if_t<!__is_duration<_Rep2>::value && is_convertible<_Rep2, typename common_type<_Rep1, _Rep2>::type>::value, int> = 0>
491 inline _LIBCPP_INLINE_VISIBILITY
492 _LIBCPP_CONSTEXPR
493 duration<typename common_type<_Rep1, _Rep2>::type, _Period>
494 operator%(const duration<_Rep1, _Period>& __d, const _Rep2& __s)
496 typedef typename common_type<_Rep1, _Rep2>::type _Cr;
497 typedef duration<_Cr, _Period> _Cd;
498 return _Cd(_Cd(__d).count() % static_cast<_Cr>(__s));
501 template <class _Rep1, class _Period1, class _Rep2, class _Period2>
502 inline _LIBCPP_INLINE_VISIBILITY
503 _LIBCPP_CONSTEXPR
504 typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type
505 operator%(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
507 typedef typename common_type<_Rep1, _Rep2>::type _Cr;
508 typedef typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type _Cd;
509 return _Cd(static_cast<_Cr>(_Cd(__lhs).count()) % static_cast<_Cr>(_Cd(__rhs).count()));
512 } // namespace chrono
514 #if _LIBCPP_STD_VER >= 14
515 // Suffixes for duration literals [time.duration.literals]
516 inline namespace literals
518 inline namespace chrono_literals
521 _LIBCPP_HIDE_FROM_ABI constexpr chrono::hours operator""h(unsigned long long __h)
523 return chrono::hours(static_cast<chrono::hours::rep>(__h));
526 _LIBCPP_HIDE_FROM_ABI constexpr chrono::duration<long double, ratio<3600,1>> operator""h(long double __h)
528 return chrono::duration<long double, ratio<3600,1>>(__h);
532 _LIBCPP_HIDE_FROM_ABI constexpr chrono::minutes operator""min(unsigned long long __m)
534 return chrono::minutes(static_cast<chrono::minutes::rep>(__m));
537 _LIBCPP_HIDE_FROM_ABI constexpr chrono::duration<long double, ratio<60,1>> operator""min(long double __m)
539 return chrono::duration<long double, ratio<60,1>> (__m);
543 _LIBCPP_HIDE_FROM_ABI constexpr chrono::seconds operator""s(unsigned long long __s)
545 return chrono::seconds(static_cast<chrono::seconds::rep>(__s));
548 _LIBCPP_HIDE_FROM_ABI constexpr chrono::duration<long double> operator""s(long double __s)
550 return chrono::duration<long double> (__s);
554 _LIBCPP_HIDE_FROM_ABI constexpr chrono::milliseconds operator""ms(unsigned long long __ms)
556 return chrono::milliseconds(static_cast<chrono::milliseconds::rep>(__ms));
559 _LIBCPP_HIDE_FROM_ABI constexpr chrono::duration<long double, milli> operator""ms(long double __ms)
561 return chrono::duration<long double, milli>(__ms);
565 _LIBCPP_HIDE_FROM_ABI constexpr chrono::microseconds operator""us(unsigned long long __us)
567 return chrono::microseconds(static_cast<chrono::microseconds::rep>(__us));
570 _LIBCPP_HIDE_FROM_ABI constexpr chrono::duration<long double, micro> operator""us(long double __us)
572 return chrono::duration<long double, micro> (__us);
576 _LIBCPP_HIDE_FROM_ABI constexpr chrono::nanoseconds operator""ns(unsigned long long __ns)
578 return chrono::nanoseconds(static_cast<chrono::nanoseconds::rep>(__ns));
581 _LIBCPP_HIDE_FROM_ABI constexpr chrono::duration<long double, nano> operator""ns(long double __ns)
583 return chrono::duration<long double, nano> (__ns);
586 } // namespace chrono_literals
587 } // namespace literals
589 namespace chrono { // hoist the literals into namespace std::chrono
590 using namespace literals::chrono_literals;
591 } // namespace chrono
593 #endif // _LIBCPP_STD_VER >= 14
595 _LIBCPP_END_NAMESPACE_STD
597 _LIBCPP_POP_MACROS
599 #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
600 # include <type_traits>
601 #endif
603 #endif // _LIBCPP___CHRONO_DURATION_H