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//===----------------------------------------------------------------------===//
9
10#ifndef _LIBCPP___CHRONO_DURATION_H
11#define _LIBCPP___CHRONO_DURATION_H
12
13#include <__config>
14#include <limits>
15#include <ratio>
16#include <type_traits>
17
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19# pragma GCC system_header
20#endif
21
22_LIBCPP_PUSH_MACROS
23#include <__undef_macros>
24
25_LIBCPP_BEGIN_NAMESPACE_STD
26
27namespace chrono
28{
29
30template <class _Rep, class _Period = ratio<1> > class _LIBCPP_TEMPLATE_VIS duration;
31
32template <class _Tp>
33struct __is_duration : false_type {};
34
35template <class _Rep, class _Period>
36struct __is_duration<duration<_Rep, _Period> > : true_type {};
37
38template <class _Rep, class _Period>
39struct __is_duration<const duration<_Rep, _Period> > : true_type {};
40
41template <class _Rep, class _Period>
42struct __is_duration<volatile duration<_Rep, _Period> > : true_type {};
43
44template <class _Rep, class _Period>
45struct __is_duration<const volatile duration<_Rep, _Period> > : true_type {};
46
47} // namespace chrono
48
49template <class _Rep1, class _Period1, class _Rep2, class _Period2>
50struct _LIBCPP_TEMPLATE_VIS common_type<chrono::duration<_Rep1, _Period1>,
51 chrono::duration<_Rep2, _Period2> >
52{
53 typedef chrono::duration<typename common_type<_Rep1, _Rep2>::type,
54 typename __ratio_gcd<_Period1, _Period2>::type> type;
55};
56
57namespace chrono {
58
59// duration_cast
60
61template <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>
65struct __duration_cast;
66
67template <class _FromDuration, class _ToDuration, class _Period>
68struct __duration_cast<_FromDuration, _ToDuration, _Period, true, true>
69{
70 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
71 _ToDuration operator()(const _FromDuration& __fd) const
72 {
73 return _ToDuration(static_cast<typename _ToDuration::rep>(__fd.count()));
74 }
75};
76
77template <class _FromDuration, class _ToDuration, class _Period>
78struct __duration_cast<_FromDuration, _ToDuration, _Period, true, false>
79{
80 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
81 _ToDuration operator()(const _FromDuration& __fd) const
82 {
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)));
86 }
87};
88
89template <class _FromDuration, class _ToDuration, class _Period>
90struct __duration_cast<_FromDuration, _ToDuration, _Period, false, true>
91{
92 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
93 _ToDuration operator()(const _FromDuration& __fd) const
94 {
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)));
98 }
99};
100
101template <class _FromDuration, class _ToDuration, class _Period>
102struct __duration_cast<_FromDuration, _ToDuration, _Period, false, false>
103{
104 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
105 _ToDuration operator()(const _FromDuration& __fd) const
106 {
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)));
111 }
112};
113
114template <class _ToDuration, class _Rep, class _Period>
115inline _LIBCPP_INLINE_VISIBILITY
116_LIBCPP_CONSTEXPR
117typename enable_if
118<
119 __is_duration<_ToDuration>::value,
120 _ToDuration
121>::type
122duration_cast(const duration<_Rep, _Period>& __fd)
123{
124 return __duration_cast<duration<_Rep, _Period>, _ToDuration>()(__fd);
125}
126
127template <class _Rep>
128struct _LIBCPP_TEMPLATE_VIS treat_as_floating_point : is_floating_point<_Rep> {};
129
130#if _LIBCPP_STD_VER > 14
131template <class _Rep>
132inline constexpr bool treat_as_floating_point_v = treat_as_floating_point<_Rep>::value;
133#endif
134
135template <class _Rep>
136struct _LIBCPP_TEMPLATE_VIS duration_values
137{
138public:
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();}
142};
143
144#if _LIBCPP_STD_VER > 14
145template <class _ToDuration, class _Rep, class _Period>
146inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
147typename enable_if
148<
149 __is_duration<_ToDuration>::value,
150 _ToDuration
151>::type
152floor(const duration<_Rep, _Period>& __d)
153{
154 _ToDuration __t = duration_cast<_ToDuration>(__d);
155 if (__t > __d)
156 __t = __t - _ToDuration{1};
157 return __t;
158}
159
160template <class _ToDuration, class _Rep, class _Period>
161inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
162typename enable_if
163<
164 __is_duration<_ToDuration>::value,
165 _ToDuration
166>::type
167ceil(const duration<_Rep, _Period>& __d)
168{
169 _ToDuration __t = duration_cast<_ToDuration>(__d);
170 if (__t < __d)
171 __t = __t + _ToDuration{1};
172 return __t;
173}
174
175template <class _ToDuration, class _Rep, class _Period>
176inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
177typename enable_if
178<
179 __is_duration<_ToDuration>::value,
180 _ToDuration
181>::type
182round(const duration<_Rep, _Period>& __d)
183{
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)
189 return __lower;
190 if (__lowerDiff > __upperDiff)
191 return __upper;
192 return __lower.count() & 1 ? __upper : __lower;
193}
194#endif
195
196// duration
197
198template <class _Rep, class _Period>
199class _LIBCPP_TEMPLATE_VIS duration
200{
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");
204
205 template <class _R1, class _R2>
206 struct __no_overflow
207 {
208 private:
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);
216
217 template <intmax_t _Xp, intmax_t _Yp, bool __overflow>
218 struct __mul // __overflow == false
219 {
220 static const intmax_t value = _Xp * _Yp;
221 };
222
223 template <intmax_t _Xp, intmax_t _Yp>
224 struct __mul<_Xp, _Yp, true>
225 {
226 static const intmax_t value = 1;
227 };
228
229 public:
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;
233 };
234
235public:
236 typedef _Rep rep;
237 typedef typename _Period::type period;
238private:
239 rep __rep_;
240public:
241
242 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
243#ifndef _LIBCPP_CXX03_LANG
244 duration() = default;
245#else
246 duration() {}
247#endif
248
249 template <class _Rep2>
250 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
251 explicit duration(const _Rep2& __r,
252 typename enable_if
253 <
254 is_convertible<const _Rep2&, rep>::value &&
255 (treat_as_floating_point<rep>::value ||
256 !treat_as_floating_point<_Rep2>::value)
257 >::type* = nullptr)
258 : __rep_(__r) {}
259
260 // conversions
261 template <class _Rep2, class _Period2>
262 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
263 duration(const duration<_Rep2, _Period2>& __d,
264 typename enable_if
265 <
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))
270 >::type* = nullptr)
271 : __rep_(chrono::duration_cast<duration>(__d).count()) {}
272
273 // observer
274
275 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR rep count() const {return __rep_;}
276
277 // arithmetic
278
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_--);}
285
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;}
288
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;}
293
294 // special values
295
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());}
299};
300
301typedef duration<long long, nano> nanoseconds;
302typedef duration<long long, micro> microseconds;
303typedef duration<long long, milli> milliseconds;
304typedef duration<long long > seconds;
305typedef duration< long, ratio< 60> > minutes;
306typedef duration< long, ratio<3600> > hours;
307#if _LIBCPP_STD_VER > 17
308typedef duration< int, ratio_multiply<ratio<24>, hours::period>> days;
309typedef duration< int, ratio_multiply<ratio<7>, days::period>> weeks;
310typedef duration< int, ratio_multiply<ratio<146097, 400>, days::period>> years;
311typedef duration< int, ratio_divide<years::period, ratio<12>>> months;
312#endif
313// Duration ==
314
315template <class _LhsDuration, class _RhsDuration>
316struct __duration_eq
317{
318 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
319 bool operator()(const _LhsDuration& __lhs, const _RhsDuration& __rhs) const
320 {
321 typedef typename common_type<_LhsDuration, _RhsDuration>::type _Ct;
322 return _Ct(__lhs).count() == _Ct(__rhs).count();
323 }
324};
325
326template <class _LhsDuration>
327struct __duration_eq<_LhsDuration, _LhsDuration>
328{
329 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
330 bool operator()(const _LhsDuration& __lhs, const _LhsDuration& __rhs) const
331 {return __lhs.count() == __rhs.count();}
332};
333
334template <class _Rep1, class _Period1, class _Rep2, class _Period2>
335inline _LIBCPP_INLINE_VISIBILITY
336_LIBCPP_CONSTEXPR
337bool
338operator==(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
339{
340 return __duration_eq<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >()(__lhs, __rhs);
341}
342
343// Duration !=
344
345template <class _Rep1, class _Period1, class _Rep2, class _Period2>
346inline _LIBCPP_INLINE_VISIBILITY
347_LIBCPP_CONSTEXPR
348bool
349operator!=(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
350{
351 return !(__lhs == __rhs);
352}
353
354// Duration <
355
356template <class _LhsDuration, class _RhsDuration>
357struct __duration_lt
358{
359 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
360 bool operator()(const _LhsDuration& __lhs, const _RhsDuration& __rhs) const
361 {
362 typedef typename common_type<_LhsDuration, _RhsDuration>::type _Ct;
363 return _Ct(__lhs).count() < _Ct(__rhs).count();
364 }
365};
366
367template <class _LhsDuration>
368struct __duration_lt<_LhsDuration, _LhsDuration>
369{
370 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
371 bool operator()(const _LhsDuration& __lhs, const _LhsDuration& __rhs) const
372 {return __lhs.count() < __rhs.count();}
373};
374
375template <class _Rep1, class _Period1, class _Rep2, class _Period2>
376inline _LIBCPP_INLINE_VISIBILITY
377_LIBCPP_CONSTEXPR
378bool
379operator< (const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
380{
381 return __duration_lt<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >()(__lhs, __rhs);
382}
383
384// Duration >
385
386template <class _Rep1, class _Period1, class _Rep2, class _Period2>
387inline _LIBCPP_INLINE_VISIBILITY
388_LIBCPP_CONSTEXPR
389bool
390operator> (const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
391{
392 return __rhs < __lhs;
393}
394
395// Duration <=
396
397template <class _Rep1, class _Period1, class _Rep2, class _Period2>
398inline _LIBCPP_INLINE_VISIBILITY
399_LIBCPP_CONSTEXPR
400bool
401operator<=(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
402{
403 return !(__rhs < __lhs);
404}
405
406// Duration >=
407
408template <class _Rep1, class _Period1, class _Rep2, class _Period2>
409inline _LIBCPP_INLINE_VISIBILITY
410_LIBCPP_CONSTEXPR
411bool
412operator>=(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
413{
414 return !(__lhs < __rhs);
415}
416
417// Duration +
418
419template <class _Rep1, class _Period1, class _Rep2, class _Period2>
420inline _LIBCPP_INLINE_VISIBILITY
421_LIBCPP_CONSTEXPR
422typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type
423operator+(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
424{
425 typedef typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type _Cd;
426 return _Cd(_Cd(__lhs).count() + _Cd(__rhs).count());
427}
428
429// Duration -
430
431template <class _Rep1, class _Period1, class _Rep2, class _Period2>
432inline _LIBCPP_INLINE_VISIBILITY
433_LIBCPP_CONSTEXPR
434typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type
435operator-(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
436{
437 typedef typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type _Cd;
438 return _Cd(_Cd(__lhs).count() - _Cd(__rhs).count());
439}
440
441// Duration *
442
443template <class _Rep1, class _Period, class _Rep2>
444inline _LIBCPP_INLINE_VISIBILITY
445_LIBCPP_CONSTEXPR
446typename enable_if
447<
448 is_convertible<_Rep2, typename common_type<_Rep1, _Rep2>::type>::value,
449 duration<typename common_type<_Rep1, _Rep2>::type, _Period>
450>::type
451operator*(const duration<_Rep1, _Period>& __d, const _Rep2& __s)
452{
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));
456}
457
458template <class _Rep1, class _Period, class _Rep2>
459inline _LIBCPP_INLINE_VISIBILITY
460_LIBCPP_CONSTEXPR
461typename enable_if
462<
463 is_convertible<_Rep1, typename common_type<_Rep1, _Rep2>::type>::value,
464 duration<typename common_type<_Rep1, _Rep2>::type, _Period>
465>::type
466operator*(const _Rep1& __s, const duration<_Rep2, _Period>& __d)
467{
468 return __d * __s;
469}
470
471// Duration /
472
473template <class _Rep1, class _Period, class _Rep2>
474inline _LIBCPP_INLINE_VISIBILITY
475_LIBCPP_CONSTEXPR
476typename enable_if
477<
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>
481>::type
482operator/(const duration<_Rep1, _Period>& __d, const _Rep2& __s)
483{
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));
487}
488
489template <class _Rep1, class _Period1, class _Rep2, class _Period2>
490inline _LIBCPP_INLINE_VISIBILITY
491_LIBCPP_CONSTEXPR
492typename common_type<_Rep1, _Rep2>::type
493operator/(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
494{
495 typedef typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type _Ct;
496 return _Ct(__lhs).count() / _Ct(__rhs).count();
497}
498
499// Duration %
500
501template <class _Rep1, class _Period, class _Rep2>
502inline _LIBCPP_INLINE_VISIBILITY
503_LIBCPP_CONSTEXPR
504typename enable_if
505<
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>
509>::type
510operator%(const duration<_Rep1, _Period>& __d, const _Rep2& __s)
511{
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));
515}
516
517template <class _Rep1, class _Period1, class _Rep2, class _Period2>
518inline _LIBCPP_INLINE_VISIBILITY
519_LIBCPP_CONSTEXPR
520typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type
521operator%(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
522{
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()));
526}
527
528} // namespace chrono
529
530#if _LIBCPP_STD_VER > 11
531// Suffixes for duration literals [time.duration.literals]
532inline namespace literals
533{
534 inline namespace chrono_literals
535 {
536
537 constexpr chrono::hours operator""h(unsigned long long __h)
538 {
539 return chrono::hours(static_cast<chrono::hours::rep>(__h));
540 }
541
542 constexpr chrono::duration<long double, ratio<3600,1>> operator""h(long double __h)
543 {
544 return chrono::duration<long double, ratio<3600,1>>(__h);
545 }
546
547
548 constexpr chrono::minutes operator""min(unsigned long long __m)
549 {
550 return chrono::minutes(static_cast<chrono::minutes::rep>(__m));
551 }
552
553 constexpr chrono::duration<long double, ratio<60,1>> operator""min(long double __m)
554 {
555 return chrono::duration<long double, ratio<60,1>> (__m);
556 }
557
558
559 constexpr chrono::seconds operator""s(unsigned long long __s)
560 {
561 return chrono::seconds(static_cast<chrono::seconds::rep>(__s));
562 }
563
564 constexpr chrono::duration<long double> operator""s(long double __s)
565 {
566 return chrono::duration<long double> (__s);
567 }
568
569
570 constexpr chrono::milliseconds operator""ms(unsigned long long __ms)
571 {
572 return chrono::milliseconds(static_cast<chrono::milliseconds::rep>(__ms));
573 }
574
575 constexpr chrono::duration<long double, milli> operator""ms(long double __ms)
576 {
577 return chrono::duration<long double, milli>(__ms);
578 }
579
580
581 constexpr chrono::microseconds operator""us(unsigned long long __us)
582 {
583 return chrono::microseconds(static_cast<chrono::microseconds::rep>(__us));
584 }
585
586 constexpr chrono::duration<long double, micro> operator""us(long double __us)
587 {
588 return chrono::duration<long double, micro> (__us);
589 }
590
591
592 constexpr chrono::nanoseconds operator""ns(unsigned long long __ns)
593 {
594 return chrono::nanoseconds(static_cast<chrono::nanoseconds::rep>(__ns));
595 }
596
597 constexpr chrono::duration<long double, nano> operator""ns(long double __ns)
598 {
599 return chrono::duration<long double, nano> (__ns);
600 }
601
602} // namespace chrono_literals
603} // namespace literals
604
605namespace chrono { // hoist the literals into namespace std::chrono
606 using namespace literals::chrono_literals;
607} // namespace chrono
608
609#endif // _LIBCPP_STD_VER > 11
610
611_LIBCPP_END_NAMESPACE_STD
612
613_LIBCPP_POP_MACROS
614
615#endif // _LIBCPP___CHRONO_DURATION_H
616

source code of flutter_engine/third_party/libcxx/include/__chrono/duration.h