xref: /minix3/external/bsd/libc++/dist/libcxx/include/chrono (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
14684ddb6SLionel Sambuc// -*- C++ -*-
24684ddb6SLionel Sambuc//===---------------------------- chrono ----------------------------------===//
34684ddb6SLionel Sambuc//
44684ddb6SLionel Sambuc//                     The LLVM Compiler Infrastructure
54684ddb6SLionel Sambuc//
64684ddb6SLionel Sambuc// This file is dual licensed under the MIT and the University of Illinois Open
74684ddb6SLionel Sambuc// Source Licenses. See LICENSE.TXT for details.
84684ddb6SLionel Sambuc//
94684ddb6SLionel Sambuc//===----------------------------------------------------------------------===//
104684ddb6SLionel Sambuc
114684ddb6SLionel Sambuc#ifndef _LIBCPP_CHRONO
124684ddb6SLionel Sambuc#define _LIBCPP_CHRONO
134684ddb6SLionel Sambuc
144684ddb6SLionel Sambuc/*
154684ddb6SLionel Sambuc    chrono synopsis
164684ddb6SLionel Sambuc
174684ddb6SLionel Sambucnamespace std
184684ddb6SLionel Sambuc{
194684ddb6SLionel Sambucnamespace chrono
204684ddb6SLionel Sambuc{
214684ddb6SLionel Sambuc
224684ddb6SLionel Sambuctemplate <class ToDuration, class Rep, class Period>
234684ddb6SLionel Sambucconstexpr
244684ddb6SLionel SambucToDuration
254684ddb6SLionel Sambucduration_cast(const duration<Rep, Period>& fd);
264684ddb6SLionel Sambuc
274684ddb6SLionel Sambuctemplate <class Rep> struct treat_as_floating_point : is_floating_point<Rep> {};
284684ddb6SLionel Sambuc
294684ddb6SLionel Sambuctemplate <class Rep>
304684ddb6SLionel Sambucstruct duration_values
314684ddb6SLionel Sambuc{
324684ddb6SLionel Sambucpublic:
334684ddb6SLionel Sambuc    static constexpr Rep zero();
344684ddb6SLionel Sambuc    static constexpr Rep max();
354684ddb6SLionel Sambuc    static constexpr Rep min();
364684ddb6SLionel Sambuc};
374684ddb6SLionel Sambuc
384684ddb6SLionel Sambuc// duration
394684ddb6SLionel Sambuc
404684ddb6SLionel Sambuctemplate <class Rep, class Period = ratio<1>>
414684ddb6SLionel Sambucclass duration
424684ddb6SLionel Sambuc{
434684ddb6SLionel Sambuc    static_assert(!__is_duration<Rep>::value, "A duration representation can not be a duration");
444684ddb6SLionel Sambuc    static_assert(__is_ratio<Period>::value, "Second template parameter of duration must be a std::ratio");
454684ddb6SLionel Sambuc    static_assert(Period::num > 0, "duration period must be positive");
464684ddb6SLionel Sambucpublic:
474684ddb6SLionel Sambuc    typedef Rep rep;
484684ddb6SLionel Sambuc    typedef Period period;
494684ddb6SLionel Sambuc
504684ddb6SLionel Sambuc    constexpr duration() = default;
514684ddb6SLionel Sambuc    template <class Rep2>
524684ddb6SLionel Sambuc        constexpr explicit duration(const Rep2& r,
534684ddb6SLionel Sambuc            typename enable_if
544684ddb6SLionel Sambuc            <
554684ddb6SLionel Sambuc               is_convertible<Rep2, rep>::value &&
564684ddb6SLionel Sambuc               (treat_as_floating_point<rep>::value ||
574684ddb6SLionel Sambuc               !treat_as_floating_point<rep>::value && !treat_as_floating_point<Rep2>::value)
584684ddb6SLionel Sambuc            >::type* = 0);
594684ddb6SLionel Sambuc
604684ddb6SLionel Sambuc    // conversions
614684ddb6SLionel Sambuc    template <class Rep2, class Period2>
624684ddb6SLionel Sambuc        constexpr duration(const duration<Rep2, Period2>& d,
634684ddb6SLionel Sambuc            typename enable_if
644684ddb6SLionel Sambuc            <
654684ddb6SLionel Sambuc                treat_as_floating_point<rep>::value ||
664684ddb6SLionel Sambuc                ratio_divide<Period2, period>::type::den == 1
674684ddb6SLionel Sambuc            >::type* = 0);
684684ddb6SLionel Sambuc
694684ddb6SLionel Sambuc    // observer
704684ddb6SLionel Sambuc
714684ddb6SLionel Sambuc    constexpr rep count() const;
724684ddb6SLionel Sambuc
734684ddb6SLionel Sambuc    // arithmetic
744684ddb6SLionel Sambuc
754684ddb6SLionel Sambuc    constexpr duration  operator+() const;
764684ddb6SLionel Sambuc    constexpr duration  operator-() const;
774684ddb6SLionel Sambuc    duration& operator++();
784684ddb6SLionel Sambuc    duration  operator++(int);
794684ddb6SLionel Sambuc    duration& operator--();
804684ddb6SLionel Sambuc    duration  operator--(int);
814684ddb6SLionel Sambuc
824684ddb6SLionel Sambuc    duration& operator+=(const duration& d);
834684ddb6SLionel Sambuc    duration& operator-=(const duration& d);
844684ddb6SLionel Sambuc
854684ddb6SLionel Sambuc    duration& operator*=(const rep& rhs);
864684ddb6SLionel Sambuc    duration& operator/=(const rep& rhs);
874684ddb6SLionel Sambuc
884684ddb6SLionel Sambuc    // special values
894684ddb6SLionel Sambuc
904684ddb6SLionel Sambuc    static constexpr duration zero();
914684ddb6SLionel Sambuc    static constexpr duration min();
924684ddb6SLionel Sambuc    static constexpr duration max();
934684ddb6SLionel Sambuc};
944684ddb6SLionel Sambuc
954684ddb6SLionel Sambuctypedef duration<long long,         nano> nanoseconds;
964684ddb6SLionel Sambuctypedef duration<long long,        micro> microseconds;
974684ddb6SLionel Sambuctypedef duration<long long,        milli> milliseconds;
984684ddb6SLionel Sambuctypedef duration<long long              > seconds;
994684ddb6SLionel Sambuctypedef duration<     long, ratio<  60> > minutes;
1004684ddb6SLionel Sambuctypedef duration<     long, ratio<3600> > hours;
1014684ddb6SLionel Sambuc
1024684ddb6SLionel Sambuctemplate <class Clock, class Duration = typename Clock::duration>
1034684ddb6SLionel Sambucclass time_point
1044684ddb6SLionel Sambuc{
1054684ddb6SLionel Sambucpublic:
1064684ddb6SLionel Sambuc    typedef Clock                     clock;
1074684ddb6SLionel Sambuc    typedef Duration                  duration;
1084684ddb6SLionel Sambuc    typedef typename duration::rep    rep;
1094684ddb6SLionel Sambuc    typedef typename duration::period period;
1104684ddb6SLionel Sambucprivate:
1114684ddb6SLionel Sambuc    duration d_;  // exposition only
1124684ddb6SLionel Sambuc
1134684ddb6SLionel Sambucpublic:
1144684ddb6SLionel Sambuc    time_point();  // has value "epoch" // constexpr in C++14
1154684ddb6SLionel Sambuc    explicit time_point(const duration& d);  // same as time_point() + d // constexpr in C++14
1164684ddb6SLionel Sambuc
1174684ddb6SLionel Sambuc    // conversions
1184684ddb6SLionel Sambuc    template <class Duration2>
1194684ddb6SLionel Sambuc       time_point(const time_point<clock, Duration2>& t); // constexpr in C++14
1204684ddb6SLionel Sambuc
1214684ddb6SLionel Sambuc    // observer
1224684ddb6SLionel Sambuc
1234684ddb6SLionel Sambuc    duration time_since_epoch() const; // constexpr in C++14
1244684ddb6SLionel Sambuc
1254684ddb6SLionel Sambuc    // arithmetic
1264684ddb6SLionel Sambuc
1274684ddb6SLionel Sambuc    time_point& operator+=(const duration& d);
1284684ddb6SLionel Sambuc    time_point& operator-=(const duration& d);
1294684ddb6SLionel Sambuc
1304684ddb6SLionel Sambuc    // special values
1314684ddb6SLionel Sambuc
1324684ddb6SLionel Sambuc    static constexpr time_point min();
1334684ddb6SLionel Sambuc    static constexpr time_point max();
1344684ddb6SLionel Sambuc};
1354684ddb6SLionel Sambuc
1364684ddb6SLionel Sambuc} // chrono
1374684ddb6SLionel Sambuc
1384684ddb6SLionel Sambuc// common_type traits
1394684ddb6SLionel Sambuctemplate <class Rep1, class Period1, class Rep2, class Period2>
1404684ddb6SLionel Sambuc  struct common_type<chrono::duration<Rep1, Period1>, chrono::duration<Rep2, Period2>>;
1414684ddb6SLionel Sambuc
1424684ddb6SLionel Sambuctemplate <class Clock, class Duration1, class Duration2>
1434684ddb6SLionel Sambuc  struct common_type<chrono::time_point<Clock, Duration1>, chrono::time_point<Clock, Duration2>>;
1444684ddb6SLionel Sambuc
1454684ddb6SLionel Sambucnamespace chrono {
1464684ddb6SLionel Sambuc
1474684ddb6SLionel Sambuc// duration arithmetic
1484684ddb6SLionel Sambuctemplate <class Rep1, class Period1, class Rep2, class Period2>
1494684ddb6SLionel Sambuc  constexpr
1504684ddb6SLionel Sambuc  typename common_type<duration<Rep1, Period1>, duration<Rep2, Period2>>::type
1514684ddb6SLionel Sambuc  operator+(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
1524684ddb6SLionel Sambuctemplate <class Rep1, class Period1, class Rep2, class Period2>
1534684ddb6SLionel Sambuc  constexpr
1544684ddb6SLionel Sambuc  typename common_type<duration<Rep1, Period1>, duration<Rep2, Period2>>::type
1554684ddb6SLionel Sambuc  operator-(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
1564684ddb6SLionel Sambuctemplate <class Rep1, class Period, class Rep2>
1574684ddb6SLionel Sambuc  constexpr
1584684ddb6SLionel Sambuc  duration<typename common_type<Rep1, Rep2>::type, Period>
1594684ddb6SLionel Sambuc  operator*(const duration<Rep1, Period>& d, const Rep2& s);
1604684ddb6SLionel Sambuctemplate <class Rep1, class Period, class Rep2>
1614684ddb6SLionel Sambuc  constexpr
1624684ddb6SLionel Sambuc  duration<typename common_type<Rep1, Rep2>::type, Period>
1634684ddb6SLionel Sambuc  operator*(const Rep1& s, const duration<Rep2, Period>& d);
1644684ddb6SLionel Sambuctemplate <class Rep1, class Period, class Rep2>
1654684ddb6SLionel Sambuc  constexpr
1664684ddb6SLionel Sambuc  duration<typename common_type<Rep1, Rep2>::type, Period>
1674684ddb6SLionel Sambuc  operator/(const duration<Rep1, Period>& d, const Rep2& s);
1684684ddb6SLionel Sambuctemplate <class Rep1, class Period1, class Rep2, class Period2>
1694684ddb6SLionel Sambuc  constexpr
1704684ddb6SLionel Sambuc  typename common_type<Rep1, Rep2>::type
1714684ddb6SLionel Sambuc  operator/(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
1724684ddb6SLionel Sambuc
1734684ddb6SLionel Sambuc// duration comparisons
1744684ddb6SLionel Sambuctemplate <class Rep1, class Period1, class Rep2, class Period2>
1754684ddb6SLionel Sambuc   constexpr
1764684ddb6SLionel Sambuc   bool operator==(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
1774684ddb6SLionel Sambuctemplate <class Rep1, class Period1, class Rep2, class Period2>
1784684ddb6SLionel Sambuc   constexpr
1794684ddb6SLionel Sambuc   bool operator!=(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
1804684ddb6SLionel Sambuctemplate <class Rep1, class Period1, class Rep2, class Period2>
1814684ddb6SLionel Sambuc   constexpr
1824684ddb6SLionel Sambuc   bool operator< (const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
1834684ddb6SLionel Sambuctemplate <class Rep1, class Period1, class Rep2, class Period2>
1844684ddb6SLionel Sambuc   constexpr
1854684ddb6SLionel Sambuc   bool operator<=(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
1864684ddb6SLionel Sambuctemplate <class Rep1, class Period1, class Rep2, class Period2>
1874684ddb6SLionel Sambuc   constexpr
1884684ddb6SLionel Sambuc   bool operator> (const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
1894684ddb6SLionel Sambuctemplate <class Rep1, class Period1, class Rep2, class Period2>
1904684ddb6SLionel Sambuc   constexpr
1914684ddb6SLionel Sambuc   bool operator>=(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
1924684ddb6SLionel Sambuc
1934684ddb6SLionel Sambuc// duration_cast
1944684ddb6SLionel Sambuctemplate <class ToDuration, class Rep, class Period>
1954684ddb6SLionel Sambuc  ToDuration duration_cast(const duration<Rep, Period>& d);
1964684ddb6SLionel Sambuc
1974684ddb6SLionel Sambuc// time_point arithmetic (all constexpr in C++14)
1984684ddb6SLionel Sambuctemplate <class Clock, class Duration1, class Rep2, class Period2>
1994684ddb6SLionel Sambuc  time_point<Clock, typename common_type<Duration1, duration<Rep2, Period2>>::type>
2004684ddb6SLionel Sambuc  operator+(const time_point<Clock, Duration1>& lhs, const duration<Rep2, Period2>& rhs);
2014684ddb6SLionel Sambuctemplate <class Rep1, class Period1, class Clock, class Duration2>
2024684ddb6SLionel Sambuc  time_point<Clock, typename common_type<duration<Rep1, Period1>, Duration2>::type>
2034684ddb6SLionel Sambuc  operator+(const duration<Rep1, Period1>& lhs, const time_point<Clock, Duration2>& rhs);
2044684ddb6SLionel Sambuctemplate <class Clock, class Duration1, class Rep2, class Period2>
2054684ddb6SLionel Sambuc  time_point<Clock, typename common_type<Duration1, duration<Rep2, Period2>>::type>
2064684ddb6SLionel Sambuc  operator-(const time_point<Clock, Duration1>& lhs, const duration<Rep2, Period2>& rhs);
2074684ddb6SLionel Sambuctemplate <class Clock, class Duration1, class Duration2>
2084684ddb6SLionel Sambuc  typename common_type<Duration1, Duration2>::type
2094684ddb6SLionel Sambuc  operator-(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
2104684ddb6SLionel Sambuc
2114684ddb6SLionel Sambuc// time_point comparisons (all constexpr in C++14)
2124684ddb6SLionel Sambuctemplate <class Clock, class Duration1, class Duration2>
2134684ddb6SLionel Sambuc   bool operator==(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
2144684ddb6SLionel Sambuctemplate <class Clock, class Duration1, class Duration2>
2154684ddb6SLionel Sambuc   bool operator!=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
2164684ddb6SLionel Sambuctemplate <class Clock, class Duration1, class Duration2>
2174684ddb6SLionel Sambuc   bool operator< (const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
2184684ddb6SLionel Sambuctemplate <class Clock, class Duration1, class Duration2>
2194684ddb6SLionel Sambuc   bool operator<=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
2204684ddb6SLionel Sambuctemplate <class Clock, class Duration1, class Duration2>
2214684ddb6SLionel Sambuc   bool operator> (const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
2224684ddb6SLionel Sambuctemplate <class Clock, class Duration1, class Duration2>
2234684ddb6SLionel Sambuc   bool operator>=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
2244684ddb6SLionel Sambuc
2254684ddb6SLionel Sambuc// time_point_cast (constexpr in C++14)
2264684ddb6SLionel Sambuc
2274684ddb6SLionel Sambuctemplate <class ToDuration, class Clock, class Duration>
2284684ddb6SLionel Sambuc  time_point<Clock, ToDuration> time_point_cast(const time_point<Clock, Duration>& t);
2294684ddb6SLionel Sambuc
2304684ddb6SLionel Sambuc// Clocks
2314684ddb6SLionel Sambuc
2324684ddb6SLionel Sambucclass system_clock
2334684ddb6SLionel Sambuc{
2344684ddb6SLionel Sambucpublic:
2354684ddb6SLionel Sambuc    typedef microseconds                     duration;
2364684ddb6SLionel Sambuc    typedef duration::rep                    rep;
2374684ddb6SLionel Sambuc    typedef duration::period                 period;
2384684ddb6SLionel Sambuc    typedef chrono::time_point<system_clock> time_point;
2394684ddb6SLionel Sambuc    static const bool is_steady =            false; // constexpr in C++14
2404684ddb6SLionel Sambuc
2414684ddb6SLionel Sambuc    static time_point now() noexcept;
2424684ddb6SLionel Sambuc    static time_t     to_time_t  (const time_point& __t) noexcept;
2434684ddb6SLionel Sambuc    static time_point from_time_t(time_t __t) noexcept;
2444684ddb6SLionel Sambuc};
2454684ddb6SLionel Sambuc
2464684ddb6SLionel Sambucclass steady_clock
2474684ddb6SLionel Sambuc{
2484684ddb6SLionel Sambucpublic:
2494684ddb6SLionel Sambuc    typedef nanoseconds                                   duration;
2504684ddb6SLionel Sambuc    typedef duration::rep                                 rep;
2514684ddb6SLionel Sambuc    typedef duration::period                              period;
2524684ddb6SLionel Sambuc    typedef chrono::time_point<steady_clock, duration>    time_point;
2534684ddb6SLionel Sambuc    static const bool is_steady =                         true; // constexpr in C++14
2544684ddb6SLionel Sambuc
2554684ddb6SLionel Sambuc    static time_point now() noexcept;
2564684ddb6SLionel Sambuc};
2574684ddb6SLionel Sambuc
2584684ddb6SLionel Sambuctypedef steady_clock high_resolution_clock;
2594684ddb6SLionel Sambuc
2604684ddb6SLionel Sambuc}  // chrono
2614684ddb6SLionel Sambuc
2624684ddb6SLionel Sambucconstexpr chrono::hours                                 operator "" h(unsigned long long); // C++14
2634684ddb6SLionel Sambucconstexpr chrono::duration<unspecified , ratio<3600,1>> operator "" h(long double); // C++14
2644684ddb6SLionel Sambucconstexpr chrono::minutes                               operator "" min(unsigned long long); // C++14
2654684ddb6SLionel Sambucconstexpr chrono::duration<unspecified , ratio<60,1>>   operator "" min(long double); // C++14
2664684ddb6SLionel Sambucconstexpr chrono::seconds                               operator "" s(unsigned long long); // C++14
2674684ddb6SLionel Sambucconstexpr chrono::duration<unspecified >                operator "" s(long double); // C++14
2684684ddb6SLionel Sambucconstexpr chrono::milliseconds                          operator "" ms(unsigned long long); // C++14
2694684ddb6SLionel Sambucconstexpr chrono::duration<unspecified , milli>         operator "" ms(long double); // C++14
2704684ddb6SLionel Sambucconstexpr chrono::microseconds                          operator "" us(unsigned long long); // C++14
2714684ddb6SLionel Sambucconstexpr chrono::duration<unspecified , micro>         operator "" us(long double); // C++14
2724684ddb6SLionel Sambucconstexpr chrono::nanoseconds                           operator "" ns(unsigned long long); // C++14
2734684ddb6SLionel Sambucconstexpr chrono::duration<unspecified , nano>          operator "" ns(long double); // C++14
2744684ddb6SLionel Sambuc
2754684ddb6SLionel Sambuc}  // std
2764684ddb6SLionel Sambuc*/
2774684ddb6SLionel Sambuc
2784684ddb6SLionel Sambuc#include <__config>
2794684ddb6SLionel Sambuc#include <ctime>
2804684ddb6SLionel Sambuc#include <type_traits>
2814684ddb6SLionel Sambuc#include <ratio>
2824684ddb6SLionel Sambuc#include <limits>
2834684ddb6SLionel Sambuc
2844684ddb6SLionel Sambuc#include <__undef_min_max>
2854684ddb6SLionel Sambuc
2864684ddb6SLionel Sambuc#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2874684ddb6SLionel Sambuc#pragma GCC system_header
2884684ddb6SLionel Sambuc#endif
2894684ddb6SLionel Sambuc
2904684ddb6SLionel Sambuc_LIBCPP_BEGIN_NAMESPACE_STD
2914684ddb6SLionel Sambuc
2924684ddb6SLionel Sambucnamespace chrono
2934684ddb6SLionel Sambuc{
2944684ddb6SLionel Sambuc
2954684ddb6SLionel Sambuctemplate <class _Rep, class _Period = ratio<1> > class _LIBCPP_TYPE_VIS_ONLY duration;
2964684ddb6SLionel Sambuc
2974684ddb6SLionel Sambuctemplate <class _Tp>
2984684ddb6SLionel Sambucstruct __is_duration : false_type {};
2994684ddb6SLionel Sambuc
3004684ddb6SLionel Sambuctemplate <class _Rep, class _Period>
3014684ddb6SLionel Sambucstruct __is_duration<duration<_Rep, _Period> > : true_type  {};
3024684ddb6SLionel Sambuc
3034684ddb6SLionel Sambuctemplate <class _Rep, class _Period>
3044684ddb6SLionel Sambucstruct __is_duration<const duration<_Rep, _Period> > : true_type  {};
3054684ddb6SLionel Sambuc
3064684ddb6SLionel Sambuctemplate <class _Rep, class _Period>
3074684ddb6SLionel Sambucstruct __is_duration<volatile duration<_Rep, _Period> > : true_type  {};
3084684ddb6SLionel Sambuc
3094684ddb6SLionel Sambuctemplate <class _Rep, class _Period>
3104684ddb6SLionel Sambucstruct __is_duration<const volatile duration<_Rep, _Period> > : true_type  {};
3114684ddb6SLionel Sambuc
3124684ddb6SLionel Sambuc} // chrono
3134684ddb6SLionel Sambuc
3144684ddb6SLionel Sambuctemplate <class _Rep1, class _Period1, class _Rep2, class _Period2>
3154684ddb6SLionel Sambucstruct _LIBCPP_TYPE_VIS_ONLY common_type<chrono::duration<_Rep1, _Period1>,
3164684ddb6SLionel Sambuc                                         chrono::duration<_Rep2, _Period2> >
3174684ddb6SLionel Sambuc{
3184684ddb6SLionel Sambuc    typedef chrono::duration<typename common_type<_Rep1, _Rep2>::type,
3194684ddb6SLionel Sambuc                             typename __ratio_gcd<_Period1, _Period2>::type> type;
3204684ddb6SLionel Sambuc};
3214684ddb6SLionel Sambuc
3224684ddb6SLionel Sambucnamespace chrono {
3234684ddb6SLionel Sambuc
3244684ddb6SLionel Sambuc// duration_cast
3254684ddb6SLionel Sambuc
3264684ddb6SLionel Sambuctemplate <class _FromDuration, class _ToDuration,
3274684ddb6SLionel Sambuc          class _Period = typename ratio_divide<typename _FromDuration::period, typename _ToDuration::period>::type,
3284684ddb6SLionel Sambuc          bool = _Period::num == 1,
3294684ddb6SLionel Sambuc          bool = _Period::den == 1>
3304684ddb6SLionel Sambucstruct __duration_cast;
3314684ddb6SLionel Sambuc
3324684ddb6SLionel Sambuctemplate <class _FromDuration, class _ToDuration, class _Period>
3334684ddb6SLionel Sambucstruct __duration_cast<_FromDuration, _ToDuration, _Period, true, true>
3344684ddb6SLionel Sambuc{
3354684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
3364684ddb6SLionel Sambuc    _ToDuration operator()(const _FromDuration& __fd) const
3374684ddb6SLionel Sambuc    {
3384684ddb6SLionel Sambuc        return _ToDuration(static_cast<typename _ToDuration::rep>(__fd.count()));
3394684ddb6SLionel Sambuc    }
3404684ddb6SLionel Sambuc};
3414684ddb6SLionel Sambuc
3424684ddb6SLionel Sambuctemplate <class _FromDuration, class _ToDuration, class _Period>
3434684ddb6SLionel Sambucstruct __duration_cast<_FromDuration, _ToDuration, _Period, true, false>
3444684ddb6SLionel Sambuc{
3454684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
3464684ddb6SLionel Sambuc    _ToDuration operator()(const _FromDuration& __fd) const
3474684ddb6SLionel Sambuc    {
3484684ddb6SLionel Sambuc        typedef typename common_type<typename _ToDuration::rep, typename _FromDuration::rep, intmax_t>::type _Ct;
3494684ddb6SLionel Sambuc        return _ToDuration(static_cast<typename _ToDuration::rep>(
3504684ddb6SLionel Sambuc                           static_cast<_Ct>(__fd.count()) / static_cast<_Ct>(_Period::den)));
3514684ddb6SLionel Sambuc    }
3524684ddb6SLionel Sambuc};
3534684ddb6SLionel Sambuc
3544684ddb6SLionel Sambuctemplate <class _FromDuration, class _ToDuration, class _Period>
3554684ddb6SLionel Sambucstruct __duration_cast<_FromDuration, _ToDuration, _Period, false, true>
3564684ddb6SLionel Sambuc{
3574684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
3584684ddb6SLionel Sambuc    _ToDuration operator()(const _FromDuration& __fd) const
3594684ddb6SLionel Sambuc    {
3604684ddb6SLionel Sambuc        typedef typename common_type<typename _ToDuration::rep, typename _FromDuration::rep, intmax_t>::type _Ct;
3614684ddb6SLionel Sambuc        return _ToDuration(static_cast<typename _ToDuration::rep>(
3624684ddb6SLionel Sambuc                           static_cast<_Ct>(__fd.count()) * static_cast<_Ct>(_Period::num)));
3634684ddb6SLionel Sambuc    }
3644684ddb6SLionel Sambuc};
3654684ddb6SLionel Sambuc
3664684ddb6SLionel Sambuctemplate <class _FromDuration, class _ToDuration, class _Period>
3674684ddb6SLionel Sambucstruct __duration_cast<_FromDuration, _ToDuration, _Period, false, false>
3684684ddb6SLionel Sambuc{
3694684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
3704684ddb6SLionel Sambuc    _ToDuration operator()(const _FromDuration& __fd) const
3714684ddb6SLionel Sambuc    {
3724684ddb6SLionel Sambuc        typedef typename common_type<typename _ToDuration::rep, typename _FromDuration::rep, intmax_t>::type _Ct;
3734684ddb6SLionel Sambuc        return _ToDuration(static_cast<typename _ToDuration::rep>(
3744684ddb6SLionel Sambuc                           static_cast<_Ct>(__fd.count()) * static_cast<_Ct>(_Period::num)
3754684ddb6SLionel Sambuc                                                          / static_cast<_Ct>(_Period::den)));
3764684ddb6SLionel Sambuc    }
3774684ddb6SLionel Sambuc};
3784684ddb6SLionel Sambuc
3794684ddb6SLionel Sambuctemplate <class _ToDuration, class _Rep, class _Period>
3804684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
3814684ddb6SLionel Sambuc_LIBCPP_CONSTEXPR
3824684ddb6SLionel Sambuctypename enable_if
3834684ddb6SLionel Sambuc<
3844684ddb6SLionel Sambuc    __is_duration<_ToDuration>::value,
3854684ddb6SLionel Sambuc    _ToDuration
3864684ddb6SLionel Sambuc>::type
3874684ddb6SLionel Sambucduration_cast(const duration<_Rep, _Period>& __fd)
3884684ddb6SLionel Sambuc{
3894684ddb6SLionel Sambuc    return __duration_cast<duration<_Rep, _Period>, _ToDuration>()(__fd);
3904684ddb6SLionel Sambuc}
3914684ddb6SLionel Sambuc
3924684ddb6SLionel Sambuctemplate <class _Rep>
3934684ddb6SLionel Sambucstruct _LIBCPP_TYPE_VIS_ONLY treat_as_floating_point : is_floating_point<_Rep> {};
3944684ddb6SLionel Sambuc
3954684ddb6SLionel Sambuctemplate <class _Rep>
3964684ddb6SLionel Sambucstruct _LIBCPP_TYPE_VIS_ONLY duration_values
3974684ddb6SLionel Sambuc{
3984684ddb6SLionel Sambucpublic:
3994684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR _Rep zero() {return _Rep(0);}
4004684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR _Rep max()  {return numeric_limits<_Rep>::max();}
4014684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR _Rep min()  {return numeric_limits<_Rep>::lowest();}
4024684ddb6SLionel Sambuc};
4034684ddb6SLionel Sambuc
4044684ddb6SLionel Sambuc// duration
4054684ddb6SLionel Sambuc
4064684ddb6SLionel Sambuctemplate <class _Rep, class _Period>
4074684ddb6SLionel Sambucclass _LIBCPP_TYPE_VIS_ONLY duration
4084684ddb6SLionel Sambuc{
4094684ddb6SLionel Sambuc    static_assert(!__is_duration<_Rep>::value, "A duration representation can not be a duration");
4104684ddb6SLionel Sambuc    static_assert(__is_ratio<_Period>::value, "Second template parameter of duration must be a std::ratio");
4114684ddb6SLionel Sambuc    static_assert(_Period::num > 0, "duration period must be positive");
4124684ddb6SLionel Sambuc
4134684ddb6SLionel Sambuc    template <class _R1, class _R2>
4144684ddb6SLionel Sambuc    struct __no_overflow
4154684ddb6SLionel Sambuc    {
4164684ddb6SLionel Sambuc    private:
4174684ddb6SLionel Sambuc        static const intmax_t __gcd_n1_n2 = __static_gcd<_R1::num, _R2::num>::value;
4184684ddb6SLionel Sambuc        static const intmax_t __gcd_d1_d2 = __static_gcd<_R1::den, _R2::den>::value;
4194684ddb6SLionel Sambuc        static const intmax_t __n1 = _R1::num / __gcd_n1_n2;
4204684ddb6SLionel Sambuc        static const intmax_t __d1 = _R1::den / __gcd_d1_d2;
4214684ddb6SLionel Sambuc        static const intmax_t __n2 = _R2::num / __gcd_n1_n2;
4224684ddb6SLionel Sambuc        static const intmax_t __d2 = _R2::den / __gcd_d1_d2;
4234684ddb6SLionel Sambuc        static const intmax_t max = -((intmax_t(1) << (sizeof(intmax_t) * CHAR_BIT - 1)) + 1);
4244684ddb6SLionel Sambuc
4254684ddb6SLionel Sambuc        template <intmax_t _Xp, intmax_t _Yp, bool __overflow>
4264684ddb6SLionel Sambuc        struct __mul    // __overflow == false
4274684ddb6SLionel Sambuc        {
4284684ddb6SLionel Sambuc            static const intmax_t value = _Xp * _Yp;
4294684ddb6SLionel Sambuc        };
4304684ddb6SLionel Sambuc
4314684ddb6SLionel Sambuc        template <intmax_t _Xp, intmax_t _Yp>
4324684ddb6SLionel Sambuc        struct __mul<_Xp, _Yp, true>
4334684ddb6SLionel Sambuc        {
4344684ddb6SLionel Sambuc            static const intmax_t value = 1;
4354684ddb6SLionel Sambuc        };
4364684ddb6SLionel Sambuc
4374684ddb6SLionel Sambuc    public:
4384684ddb6SLionel Sambuc        static const bool value = (__n1 <= max / __d2) && (__n2 <= max / __d1);
4394684ddb6SLionel Sambuc        typedef ratio<__mul<__n1, __d2, !value>::value,
4404684ddb6SLionel Sambuc                      __mul<__n2, __d1, !value>::value> type;
4414684ddb6SLionel Sambuc    };
4424684ddb6SLionel Sambuc
4434684ddb6SLionel Sambucpublic:
4444684ddb6SLionel Sambuc    typedef _Rep rep;
4454684ddb6SLionel Sambuc    typedef _Period period;
4464684ddb6SLionel Sambucprivate:
4474684ddb6SLionel Sambuc    rep __rep_;
4484684ddb6SLionel Sambucpublic:
4494684ddb6SLionel Sambuc
4504684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
4514684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
4524684ddb6SLionel Sambuc        duration() = default;
4534684ddb6SLionel Sambuc#else
4544684ddb6SLionel Sambuc        duration() {}
4554684ddb6SLionel Sambuc#endif
4564684ddb6SLionel Sambuc
4574684ddb6SLionel Sambuc    template <class _Rep2>
4584684ddb6SLionel Sambuc        _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
4594684ddb6SLionel Sambuc        explicit duration(const _Rep2& __r,
4604684ddb6SLionel Sambuc            typename enable_if
4614684ddb6SLionel Sambuc            <
4624684ddb6SLionel Sambuc               is_convertible<_Rep2, rep>::value &&
4634684ddb6SLionel Sambuc               (treat_as_floating_point<rep>::value ||
4644684ddb6SLionel Sambuc               !treat_as_floating_point<_Rep2>::value)
4654684ddb6SLionel Sambuc            >::type* = 0)
4664684ddb6SLionel Sambuc                : __rep_(__r) {}
4674684ddb6SLionel Sambuc
4684684ddb6SLionel Sambuc    // conversions
4694684ddb6SLionel Sambuc    template <class _Rep2, class _Period2>
4704684ddb6SLionel Sambuc        _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
4714684ddb6SLionel Sambuc        duration(const duration<_Rep2, _Period2>& __d,
4724684ddb6SLionel Sambuc            typename enable_if
4734684ddb6SLionel Sambuc            <
4744684ddb6SLionel Sambuc                __no_overflow<_Period2, period>::value && (
4754684ddb6SLionel Sambuc                treat_as_floating_point<rep>::value ||
4764684ddb6SLionel Sambuc                (__no_overflow<_Period2, period>::type::den == 1 &&
4774684ddb6SLionel Sambuc                 !treat_as_floating_point<_Rep2>::value))
4784684ddb6SLionel Sambuc            >::type* = 0)
4794684ddb6SLionel Sambuc                : __rep_(_VSTD::chrono::duration_cast<duration>(__d).count()) {}
4804684ddb6SLionel Sambuc
4814684ddb6SLionel Sambuc    // observer
4824684ddb6SLionel Sambuc
4834684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR rep count() const {return __rep_;}
4844684ddb6SLionel Sambuc
4854684ddb6SLionel Sambuc    // arithmetic
4864684ddb6SLionel Sambuc
4874684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR duration  operator+() const {return *this;}
4884684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR duration  operator-() const {return duration(-__rep_);}
4894684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY duration& operator++()      {++__rep_; return *this;}
4904684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY duration  operator++(int)   {return duration(__rep_++);}
4914684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY duration& operator--()      {--__rep_; return *this;}
4924684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY duration  operator--(int)   {return duration(__rep_--);}
4934684ddb6SLionel Sambuc
4944684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY duration& operator+=(const duration& __d) {__rep_ += __d.count(); return *this;}
4954684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY duration& operator-=(const duration& __d) {__rep_ -= __d.count(); return *this;}
4964684ddb6SLionel Sambuc
4974684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY duration& operator*=(const rep& rhs) {__rep_ *= rhs; return *this;}
4984684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY duration& operator/=(const rep& rhs) {__rep_ /= rhs; return *this;}
4994684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY duration& operator%=(const rep& rhs) {__rep_ %= rhs; return *this;}
5004684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY duration& operator%=(const duration& rhs) {__rep_ %= rhs.count(); return *this;}
5014684ddb6SLionel Sambuc
5024684ddb6SLionel Sambuc    // special values
5034684ddb6SLionel Sambuc
5044684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR duration zero() {return duration(duration_values<rep>::zero());}
5054684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR duration min()  {return duration(duration_values<rep>::min());}
5064684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR duration max()  {return duration(duration_values<rep>::max());}
5074684ddb6SLionel Sambuc};
5084684ddb6SLionel Sambuc
5094684ddb6SLionel Sambuctypedef duration<long long,         nano> nanoseconds;
5104684ddb6SLionel Sambuctypedef duration<long long,        micro> microseconds;
5114684ddb6SLionel Sambuctypedef duration<long long,        milli> milliseconds;
5124684ddb6SLionel Sambuctypedef duration<long long              > seconds;
5134684ddb6SLionel Sambuctypedef duration<     long, ratio<  60> > minutes;
5144684ddb6SLionel Sambuctypedef duration<     long, ratio<3600> > hours;
5154684ddb6SLionel Sambuc
5164684ddb6SLionel Sambuc// Duration ==
5174684ddb6SLionel Sambuc
5184684ddb6SLionel Sambuctemplate <class _LhsDuration, class _RhsDuration>
5194684ddb6SLionel Sambucstruct __duration_eq
5204684ddb6SLionel Sambuc{
5214684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
5224684ddb6SLionel Sambuc    bool operator()(const _LhsDuration& __lhs, const _RhsDuration& __rhs) const
5234684ddb6SLionel Sambuc        {
5244684ddb6SLionel Sambuc            typedef typename common_type<_LhsDuration, _RhsDuration>::type _Ct;
5254684ddb6SLionel Sambuc            return _Ct(__lhs).count() == _Ct(__rhs).count();
5264684ddb6SLionel Sambuc        }
5274684ddb6SLionel Sambuc};
5284684ddb6SLionel Sambuc
5294684ddb6SLionel Sambuctemplate <class _LhsDuration>
5304684ddb6SLionel Sambucstruct __duration_eq<_LhsDuration, _LhsDuration>
5314684ddb6SLionel Sambuc{
5324684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
5334684ddb6SLionel Sambuc    bool operator()(const _LhsDuration& __lhs, const _LhsDuration& __rhs) const
5344684ddb6SLionel Sambuc        {return __lhs.count() == __rhs.count();}
5354684ddb6SLionel Sambuc};
5364684ddb6SLionel Sambuc
5374684ddb6SLionel Sambuctemplate <class _Rep1, class _Period1, class _Rep2, class _Period2>
5384684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
5394684ddb6SLionel Sambuc_LIBCPP_CONSTEXPR
5404684ddb6SLionel Sambucbool
5414684ddb6SLionel Sambucoperator==(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
5424684ddb6SLionel Sambuc{
5434684ddb6SLionel Sambuc    return __duration_eq<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >()(__lhs, __rhs);
5444684ddb6SLionel Sambuc}
5454684ddb6SLionel Sambuc
5464684ddb6SLionel Sambuc// Duration !=
5474684ddb6SLionel Sambuc
5484684ddb6SLionel Sambuctemplate <class _Rep1, class _Period1, class _Rep2, class _Period2>
5494684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
5504684ddb6SLionel Sambuc_LIBCPP_CONSTEXPR
5514684ddb6SLionel Sambucbool
5524684ddb6SLionel Sambucoperator!=(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
5534684ddb6SLionel Sambuc{
5544684ddb6SLionel Sambuc    return !(__lhs == __rhs);
5554684ddb6SLionel Sambuc}
5564684ddb6SLionel Sambuc
5574684ddb6SLionel Sambuc// Duration <
5584684ddb6SLionel Sambuc
5594684ddb6SLionel Sambuctemplate <class _LhsDuration, class _RhsDuration>
5604684ddb6SLionel Sambucstruct __duration_lt
5614684ddb6SLionel Sambuc{
5624684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
5634684ddb6SLionel Sambuc    bool operator()(const _LhsDuration& __lhs, const _RhsDuration& __rhs) const
5644684ddb6SLionel Sambuc        {
5654684ddb6SLionel Sambuc            typedef typename common_type<_LhsDuration, _RhsDuration>::type _Ct;
5664684ddb6SLionel Sambuc            return _Ct(__lhs).count() < _Ct(__rhs).count();
5674684ddb6SLionel Sambuc        }
5684684ddb6SLionel Sambuc};
5694684ddb6SLionel Sambuc
5704684ddb6SLionel Sambuctemplate <class _LhsDuration>
5714684ddb6SLionel Sambucstruct __duration_lt<_LhsDuration, _LhsDuration>
5724684ddb6SLionel Sambuc{
5734684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
5744684ddb6SLionel Sambuc    bool operator()(const _LhsDuration& __lhs, const _LhsDuration& __rhs) const
5754684ddb6SLionel Sambuc        {return __lhs.count() < __rhs.count();}
5764684ddb6SLionel Sambuc};
5774684ddb6SLionel Sambuc
5784684ddb6SLionel Sambuctemplate <class _Rep1, class _Period1, class _Rep2, class _Period2>
5794684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
5804684ddb6SLionel Sambuc_LIBCPP_CONSTEXPR
5814684ddb6SLionel Sambucbool
5824684ddb6SLionel Sambucoperator< (const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
5834684ddb6SLionel Sambuc{
5844684ddb6SLionel Sambuc    return __duration_lt<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >()(__lhs, __rhs);
5854684ddb6SLionel Sambuc}
5864684ddb6SLionel Sambuc
5874684ddb6SLionel Sambuc// Duration >
5884684ddb6SLionel Sambuc
5894684ddb6SLionel Sambuctemplate <class _Rep1, class _Period1, class _Rep2, class _Period2>
5904684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
5914684ddb6SLionel Sambuc_LIBCPP_CONSTEXPR
5924684ddb6SLionel Sambucbool
5934684ddb6SLionel Sambucoperator> (const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
5944684ddb6SLionel Sambuc{
5954684ddb6SLionel Sambuc    return __rhs < __lhs;
5964684ddb6SLionel Sambuc}
5974684ddb6SLionel Sambuc
5984684ddb6SLionel Sambuc// Duration <=
5994684ddb6SLionel Sambuc
6004684ddb6SLionel Sambuctemplate <class _Rep1, class _Period1, class _Rep2, class _Period2>
6014684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
6024684ddb6SLionel Sambuc_LIBCPP_CONSTEXPR
6034684ddb6SLionel Sambucbool
6044684ddb6SLionel Sambucoperator<=(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
6054684ddb6SLionel Sambuc{
6064684ddb6SLionel Sambuc    return !(__rhs < __lhs);
6074684ddb6SLionel Sambuc}
6084684ddb6SLionel Sambuc
6094684ddb6SLionel Sambuc// Duration >=
6104684ddb6SLionel Sambuc
6114684ddb6SLionel Sambuctemplate <class _Rep1, class _Period1, class _Rep2, class _Period2>
6124684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
6134684ddb6SLionel Sambuc_LIBCPP_CONSTEXPR
6144684ddb6SLionel Sambucbool
6154684ddb6SLionel Sambucoperator>=(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
6164684ddb6SLionel Sambuc{
6174684ddb6SLionel Sambuc    return !(__lhs < __rhs);
6184684ddb6SLionel Sambuc}
6194684ddb6SLionel Sambuc
6204684ddb6SLionel Sambuc// Duration +
6214684ddb6SLionel Sambuc
6224684ddb6SLionel Sambuctemplate <class _Rep1, class _Period1, class _Rep2, class _Period2>
6234684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
6244684ddb6SLionel Sambuc_LIBCPP_CONSTEXPR
6254684ddb6SLionel Sambuctypename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type
6264684ddb6SLionel Sambucoperator+(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
6274684ddb6SLionel Sambuc{
6284684ddb6SLionel Sambuc    typedef typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type _Cd;
6294684ddb6SLionel Sambuc    return _Cd(_Cd(__lhs).count() + _Cd(__rhs).count());
6304684ddb6SLionel Sambuc}
6314684ddb6SLionel Sambuc
6324684ddb6SLionel Sambuc// Duration -
6334684ddb6SLionel Sambuc
6344684ddb6SLionel Sambuctemplate <class _Rep1, class _Period1, class _Rep2, class _Period2>
6354684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
6364684ddb6SLionel Sambuc_LIBCPP_CONSTEXPR
6374684ddb6SLionel Sambuctypename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type
6384684ddb6SLionel Sambucoperator-(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
6394684ddb6SLionel Sambuc{
6404684ddb6SLionel Sambuc    typedef typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type _Cd;
6414684ddb6SLionel Sambuc    return _Cd(_Cd(__lhs).count() - _Cd(__rhs).count());
6424684ddb6SLionel Sambuc}
6434684ddb6SLionel Sambuc
6444684ddb6SLionel Sambuc// Duration *
6454684ddb6SLionel Sambuc
6464684ddb6SLionel Sambuctemplate <class _Rep1, class _Period, class _Rep2>
6474684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
6484684ddb6SLionel Sambuc_LIBCPP_CONSTEXPR
6494684ddb6SLionel Sambuctypename enable_if
6504684ddb6SLionel Sambuc<
6514684ddb6SLionel Sambuc    is_convertible<_Rep2, typename common_type<_Rep1, _Rep2>::type>::value,
6524684ddb6SLionel Sambuc    duration<typename common_type<_Rep1, _Rep2>::type, _Period>
6534684ddb6SLionel Sambuc>::type
6544684ddb6SLionel Sambucoperator*(const duration<_Rep1, _Period>& __d, const _Rep2& __s)
6554684ddb6SLionel Sambuc{
6564684ddb6SLionel Sambuc    typedef typename common_type<_Rep1, _Rep2>::type _Cr;
6574684ddb6SLionel Sambuc    typedef duration<_Cr, _Period> _Cd;
6584684ddb6SLionel Sambuc    return _Cd(_Cd(__d).count() * static_cast<_Cr>(__s));
6594684ddb6SLionel Sambuc}
6604684ddb6SLionel Sambuc
6614684ddb6SLionel Sambuctemplate <class _Rep1, class _Period, class _Rep2>
6624684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
6634684ddb6SLionel Sambuc_LIBCPP_CONSTEXPR
6644684ddb6SLionel Sambuctypename enable_if
6654684ddb6SLionel Sambuc<
6664684ddb6SLionel Sambuc    is_convertible<_Rep1, typename common_type<_Rep1, _Rep2>::type>::value,
6674684ddb6SLionel Sambuc    duration<typename common_type<_Rep1, _Rep2>::type, _Period>
6684684ddb6SLionel Sambuc>::type
6694684ddb6SLionel Sambucoperator*(const _Rep1& __s, const duration<_Rep2, _Period>& __d)
6704684ddb6SLionel Sambuc{
6714684ddb6SLionel Sambuc    return __d * __s;
6724684ddb6SLionel Sambuc}
6734684ddb6SLionel Sambuc
6744684ddb6SLionel Sambuc// Duration /
6754684ddb6SLionel Sambuc
6764684ddb6SLionel Sambuctemplate <class _Duration, class _Rep, bool = __is_duration<_Rep>::value>
6774684ddb6SLionel Sambucstruct __duration_divide_result
6784684ddb6SLionel Sambuc{
6794684ddb6SLionel Sambuc};
6804684ddb6SLionel Sambuc
6814684ddb6SLionel Sambuctemplate <class _Duration, class _Rep2,
6824684ddb6SLionel Sambuc    bool = is_convertible<_Rep2,
6834684ddb6SLionel Sambuc                          typename common_type<typename _Duration::rep, _Rep2>::type>::value>
6844684ddb6SLionel Sambucstruct __duration_divide_imp
6854684ddb6SLionel Sambuc{
6864684ddb6SLionel Sambuc};
6874684ddb6SLionel Sambuc
6884684ddb6SLionel Sambuctemplate <class _Rep1, class _Period, class _Rep2>
6894684ddb6SLionel Sambucstruct __duration_divide_imp<duration<_Rep1, _Period>, _Rep2, true>
6904684ddb6SLionel Sambuc{
6914684ddb6SLionel Sambuc    typedef duration<typename common_type<_Rep1, _Rep2>::type, _Period> type;
6924684ddb6SLionel Sambuc};
6934684ddb6SLionel Sambuc
6944684ddb6SLionel Sambuctemplate <class _Rep1, class _Period, class _Rep2>
6954684ddb6SLionel Sambucstruct __duration_divide_result<duration<_Rep1, _Period>, _Rep2, false>
6964684ddb6SLionel Sambuc    : __duration_divide_imp<duration<_Rep1, _Period>, _Rep2>
6974684ddb6SLionel Sambuc{
6984684ddb6SLionel Sambuc};
6994684ddb6SLionel Sambuc
7004684ddb6SLionel Sambuctemplate <class _Rep1, class _Period, class _Rep2>
7014684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
7024684ddb6SLionel Sambuc_LIBCPP_CONSTEXPR
7034684ddb6SLionel Sambuctypename __duration_divide_result<duration<_Rep1, _Period>, _Rep2>::type
7044684ddb6SLionel Sambucoperator/(const duration<_Rep1, _Period>& __d, const _Rep2& __s)
7054684ddb6SLionel Sambuc{
7064684ddb6SLionel Sambuc    typedef typename common_type<_Rep1, _Rep2>::type _Cr;
7074684ddb6SLionel Sambuc    typedef duration<_Cr, _Period> _Cd;
7084684ddb6SLionel Sambuc    return _Cd(_Cd(__d).count() / static_cast<_Cr>(__s));
7094684ddb6SLionel Sambuc}
7104684ddb6SLionel Sambuc
7114684ddb6SLionel Sambuctemplate <class _Rep1, class _Period1, class _Rep2, class _Period2>
7124684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
7134684ddb6SLionel Sambuc_LIBCPP_CONSTEXPR
7144684ddb6SLionel Sambuctypename common_type<_Rep1, _Rep2>::type
7154684ddb6SLionel Sambucoperator/(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
7164684ddb6SLionel Sambuc{
7174684ddb6SLionel Sambuc    typedef typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type _Ct;
7184684ddb6SLionel Sambuc    return _Ct(__lhs).count() / _Ct(__rhs).count();
7194684ddb6SLionel Sambuc}
7204684ddb6SLionel Sambuc
7214684ddb6SLionel Sambuc// Duration %
7224684ddb6SLionel Sambuc
7234684ddb6SLionel Sambuctemplate <class _Rep1, class _Period, class _Rep2>
7244684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
7254684ddb6SLionel Sambuc_LIBCPP_CONSTEXPR
7264684ddb6SLionel Sambuctypename __duration_divide_result<duration<_Rep1, _Period>, _Rep2>::type
7274684ddb6SLionel Sambucoperator%(const duration<_Rep1, _Period>& __d, const _Rep2& __s)
7284684ddb6SLionel Sambuc{
7294684ddb6SLionel Sambuc    typedef typename common_type<_Rep1, _Rep2>::type _Cr;
7304684ddb6SLionel Sambuc    typedef duration<_Cr, _Period> _Cd;
7314684ddb6SLionel Sambuc    return _Cd(_Cd(__d).count() % static_cast<_Cr>(__s));
7324684ddb6SLionel Sambuc}
7334684ddb6SLionel Sambuc
7344684ddb6SLionel Sambuctemplate <class _Rep1, class _Period1, class _Rep2, class _Period2>
7354684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
7364684ddb6SLionel Sambuc_LIBCPP_CONSTEXPR
7374684ddb6SLionel Sambuctypename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type
7384684ddb6SLionel Sambucoperator%(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
7394684ddb6SLionel Sambuc{
7404684ddb6SLionel Sambuc    typedef typename common_type<_Rep1, _Rep2>::type _Cr;
7414684ddb6SLionel Sambuc    typedef typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type _Cd;
7424684ddb6SLionel Sambuc    return _Cd(static_cast<_Cr>(_Cd(__lhs).count()) % static_cast<_Cr>(_Cd(__rhs).count()));
7434684ddb6SLionel Sambuc}
7444684ddb6SLionel Sambuc
7454684ddb6SLionel Sambuc//////////////////////////////////////////////////////////
7464684ddb6SLionel Sambuc///////////////////// time_point /////////////////////////
7474684ddb6SLionel Sambuc//////////////////////////////////////////////////////////
7484684ddb6SLionel Sambuc
7494684ddb6SLionel Sambuctemplate <class _Clock, class _Duration = typename _Clock::duration>
7504684ddb6SLionel Sambucclass _LIBCPP_TYPE_VIS_ONLY time_point
7514684ddb6SLionel Sambuc{
7524684ddb6SLionel Sambuc    static_assert(__is_duration<_Duration>::value,
7534684ddb6SLionel Sambuc                  "Second template parameter of time_point must be a std::chrono::duration");
7544684ddb6SLionel Sambucpublic:
7554684ddb6SLionel Sambuc    typedef _Clock                    clock;
7564684ddb6SLionel Sambuc    typedef _Duration                 duration;
7574684ddb6SLionel Sambuc    typedef typename duration::rep    rep;
7584684ddb6SLionel Sambuc    typedef typename duration::period period;
7594684ddb6SLionel Sambucprivate:
7604684ddb6SLionel Sambuc    duration __d_;
7614684ddb6SLionel Sambuc
7624684ddb6SLionel Sambucpublic:
7634684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 time_point() : __d_(duration::zero()) {}
7644684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 explicit time_point(const duration& __d) : __d_(__d) {}
7654684ddb6SLionel Sambuc
7664684ddb6SLionel Sambuc    // conversions
7674684ddb6SLionel Sambuc    template <class _Duration2>
7684684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
7694684ddb6SLionel Sambuc    time_point(const time_point<clock, _Duration2>& t,
7704684ddb6SLionel Sambuc        typename enable_if
7714684ddb6SLionel Sambuc        <
7724684ddb6SLionel Sambuc            is_convertible<_Duration2, duration>::value
7734684ddb6SLionel Sambuc        >::type* = 0)
7744684ddb6SLionel Sambuc            : __d_(t.time_since_epoch()) {}
7754684ddb6SLionel Sambuc
7764684ddb6SLionel Sambuc    // observer
7774684ddb6SLionel Sambuc
7784684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 duration time_since_epoch() const {return __d_;}
7794684ddb6SLionel Sambuc
7804684ddb6SLionel Sambuc    // arithmetic
7814684ddb6SLionel Sambuc
7824684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY time_point& operator+=(const duration& __d) {__d_ += __d; return *this;}
7834684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY time_point& operator-=(const duration& __d) {__d_ -= __d; return *this;}
7844684ddb6SLionel Sambuc
7854684ddb6SLionel Sambuc    // special values
7864684ddb6SLionel Sambuc
7874684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR time_point min() {return time_point(duration::min());}
7884684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR time_point max() {return time_point(duration::max());}
7894684ddb6SLionel Sambuc};
7904684ddb6SLionel Sambuc
7914684ddb6SLionel Sambuc} // chrono
7924684ddb6SLionel Sambuc
7934684ddb6SLionel Sambuctemplate <class _Clock, class _Duration1, class _Duration2>
7944684ddb6SLionel Sambucstruct _LIBCPP_TYPE_VIS_ONLY common_type<chrono::time_point<_Clock, _Duration1>,
7954684ddb6SLionel Sambuc                                         chrono::time_point<_Clock, _Duration2> >
7964684ddb6SLionel Sambuc{
7974684ddb6SLionel Sambuc    typedef chrono::time_point<_Clock, typename common_type<_Duration1, _Duration2>::type> type;
7984684ddb6SLionel Sambuc};
7994684ddb6SLionel Sambuc
8004684ddb6SLionel Sambucnamespace chrono {
8014684ddb6SLionel Sambuc
8024684ddb6SLionel Sambuctemplate <class _ToDuration, class _Clock, class _Duration>
8034684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
8044684ddb6SLionel Sambuctime_point<_Clock, _ToDuration>
8054684ddb6SLionel Sambuctime_point_cast(const time_point<_Clock, _Duration>& __t)
8064684ddb6SLionel Sambuc{
8074684ddb6SLionel Sambuc    return time_point<_Clock, _ToDuration>(_VSTD::chrono::duration_cast<_ToDuration>(__t.time_since_epoch()));
8084684ddb6SLionel Sambuc}
8094684ddb6SLionel Sambuc
8104684ddb6SLionel Sambuc// time_point ==
8114684ddb6SLionel Sambuc
8124684ddb6SLionel Sambuctemplate <class _Clock, class _Duration1, class _Duration2>
8134684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
8144684ddb6SLionel Sambucbool
8154684ddb6SLionel Sambucoperator==(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
8164684ddb6SLionel Sambuc{
8174684ddb6SLionel Sambuc    return __lhs.time_since_epoch() == __rhs.time_since_epoch();
8184684ddb6SLionel Sambuc}
8194684ddb6SLionel Sambuc
8204684ddb6SLionel Sambuc// time_point !=
8214684ddb6SLionel Sambuc
8224684ddb6SLionel Sambuctemplate <class _Clock, class _Duration1, class _Duration2>
8234684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
8244684ddb6SLionel Sambucbool
8254684ddb6SLionel Sambucoperator!=(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
8264684ddb6SLionel Sambuc{
8274684ddb6SLionel Sambuc    return !(__lhs == __rhs);
8284684ddb6SLionel Sambuc}
8294684ddb6SLionel Sambuc
8304684ddb6SLionel Sambuc// time_point <
8314684ddb6SLionel Sambuc
8324684ddb6SLionel Sambuctemplate <class _Clock, class _Duration1, class _Duration2>
8334684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
8344684ddb6SLionel Sambucbool
8354684ddb6SLionel Sambucoperator<(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
8364684ddb6SLionel Sambuc{
8374684ddb6SLionel Sambuc    return __lhs.time_since_epoch() < __rhs.time_since_epoch();
8384684ddb6SLionel Sambuc}
8394684ddb6SLionel Sambuc
8404684ddb6SLionel Sambuc// time_point >
8414684ddb6SLionel Sambuc
8424684ddb6SLionel Sambuctemplate <class _Clock, class _Duration1, class _Duration2>
8434684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
8444684ddb6SLionel Sambucbool
8454684ddb6SLionel Sambucoperator>(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
8464684ddb6SLionel Sambuc{
8474684ddb6SLionel Sambuc    return __rhs < __lhs;
8484684ddb6SLionel Sambuc}
8494684ddb6SLionel Sambuc
8504684ddb6SLionel Sambuc// time_point <=
8514684ddb6SLionel Sambuc
8524684ddb6SLionel Sambuctemplate <class _Clock, class _Duration1, class _Duration2>
8534684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
8544684ddb6SLionel Sambucbool
8554684ddb6SLionel Sambucoperator<=(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
8564684ddb6SLionel Sambuc{
8574684ddb6SLionel Sambuc    return !(__rhs < __lhs);
8584684ddb6SLionel Sambuc}
8594684ddb6SLionel Sambuc
8604684ddb6SLionel Sambuc// time_point >=
8614684ddb6SLionel Sambuc
8624684ddb6SLionel Sambuctemplate <class _Clock, class _Duration1, class _Duration2>
8634684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
8644684ddb6SLionel Sambucbool
8654684ddb6SLionel Sambucoperator>=(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
8664684ddb6SLionel Sambuc{
8674684ddb6SLionel Sambuc    return !(__lhs < __rhs);
8684684ddb6SLionel Sambuc}
8694684ddb6SLionel Sambuc
8704684ddb6SLionel Sambuc// time_point operator+(time_point x, duration y);
8714684ddb6SLionel Sambuc
8724684ddb6SLionel Sambuctemplate <class _Clock, class _Duration1, class _Rep2, class _Period2>
8734684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
8744684ddb6SLionel Sambuctime_point<_Clock, typename common_type<_Duration1, duration<_Rep2, _Period2> >::type>
8754684ddb6SLionel Sambucoperator+(const time_point<_Clock, _Duration1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
8764684ddb6SLionel Sambuc{
8774684ddb6SLionel Sambuc    typedef time_point<_Clock, typename common_type<_Duration1, duration<_Rep2, _Period2> >::type> _Tr;
8784684ddb6SLionel Sambuc    return _Tr (__lhs.time_since_epoch() + __rhs);
8794684ddb6SLionel Sambuc}
8804684ddb6SLionel Sambuc
8814684ddb6SLionel Sambuc// time_point operator+(duration x, time_point y);
8824684ddb6SLionel Sambuc
8834684ddb6SLionel Sambuctemplate <class _Rep1, class _Period1, class _Clock, class _Duration2>
8844684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
8854684ddb6SLionel Sambuctime_point<_Clock, typename common_type<duration<_Rep1, _Period1>, _Duration2>::type>
8864684ddb6SLionel Sambucoperator+(const duration<_Rep1, _Period1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
8874684ddb6SLionel Sambuc{
8884684ddb6SLionel Sambuc    return __rhs + __lhs;
8894684ddb6SLionel Sambuc}
8904684ddb6SLionel Sambuc
8914684ddb6SLionel Sambuc// time_point operator-(time_point x, duration y);
8924684ddb6SLionel Sambuc
8934684ddb6SLionel Sambuctemplate <class _Clock, class _Duration1, class _Rep2, class _Period2>
8944684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
8954684ddb6SLionel Sambuctime_point<_Clock, typename common_type<_Duration1, duration<_Rep2, _Period2> >::type>
8964684ddb6SLionel Sambucoperator-(const time_point<_Clock, _Duration1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
8974684ddb6SLionel Sambuc{
8984684ddb6SLionel Sambuc    return __lhs + (-__rhs);
8994684ddb6SLionel Sambuc}
9004684ddb6SLionel Sambuc
9014684ddb6SLionel Sambuc// duration operator-(time_point x, time_point y);
9024684ddb6SLionel Sambuc
9034684ddb6SLionel Sambuctemplate <class _Clock, class _Duration1, class _Duration2>
9044684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
9054684ddb6SLionel Sambuctypename common_type<_Duration1, _Duration2>::type
9064684ddb6SLionel Sambucoperator-(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
9074684ddb6SLionel Sambuc{
9084684ddb6SLionel Sambuc    return __lhs.time_since_epoch() - __rhs.time_since_epoch();
9094684ddb6SLionel Sambuc}
9104684ddb6SLionel Sambuc
9114684ddb6SLionel Sambuc//////////////////////////////////////////////////////////
9124684ddb6SLionel Sambuc/////////////////////// clocks ///////////////////////////
9134684ddb6SLionel Sambuc//////////////////////////////////////////////////////////
9144684ddb6SLionel Sambuc
9154684ddb6SLionel Sambucclass _LIBCPP_TYPE_VIS system_clock
9164684ddb6SLionel Sambuc{
9174684ddb6SLionel Sambucpublic:
9184684ddb6SLionel Sambuc    typedef microseconds                     duration;
9194684ddb6SLionel Sambuc    typedef duration::rep                    rep;
9204684ddb6SLionel Sambuc    typedef duration::period                 period;
9214684ddb6SLionel Sambuc    typedef chrono::time_point<system_clock> time_point;
9224684ddb6SLionel Sambuc    static _LIBCPP_CONSTEXPR_AFTER_CXX11 const bool is_steady = false;
9234684ddb6SLionel Sambuc
9244684ddb6SLionel Sambuc    static time_point now() _NOEXCEPT;
9254684ddb6SLionel Sambuc    static time_t     to_time_t  (const time_point& __t) _NOEXCEPT;
9264684ddb6SLionel Sambuc    static time_point from_time_t(time_t __t) _NOEXCEPT;
9274684ddb6SLionel Sambuc};
9284684ddb6SLionel Sambuc
929*0a6a1f1dSLionel Sambuc#ifndef _LIBCPP_HAS_NO_MONOTONIC_CLOCK
9304684ddb6SLionel Sambucclass _LIBCPP_TYPE_VIS steady_clock
9314684ddb6SLionel Sambuc{
9324684ddb6SLionel Sambucpublic:
9334684ddb6SLionel Sambuc    typedef nanoseconds                                   duration;
9344684ddb6SLionel Sambuc    typedef duration::rep                                 rep;
9354684ddb6SLionel Sambuc    typedef duration::period                              period;
9364684ddb6SLionel Sambuc    typedef chrono::time_point<steady_clock, duration>    time_point;
9374684ddb6SLionel Sambuc    static _LIBCPP_CONSTEXPR_AFTER_CXX11 const bool is_steady = true;
9384684ddb6SLionel Sambuc
9394684ddb6SLionel Sambuc    static time_point now() _NOEXCEPT;
9404684ddb6SLionel Sambuc};
9414684ddb6SLionel Sambuc
9424684ddb6SLionel Sambuctypedef steady_clock high_resolution_clock;
943*0a6a1f1dSLionel Sambuc#else
944*0a6a1f1dSLionel Sambuctypedef system_clock high_resolution_clock;
945*0a6a1f1dSLionel Sambuc#endif
9464684ddb6SLionel Sambuc
9474684ddb6SLionel Sambuc} // chrono
9484684ddb6SLionel Sambuc
9494684ddb6SLionel Sambuc#if _LIBCPP_STD_VER > 11
9504684ddb6SLionel Sambuc// Suffixes for duration literals [time.duration.literals]
9514684ddb6SLionel Sambucinline namespace literals
9524684ddb6SLionel Sambuc{
9534684ddb6SLionel Sambuc  inline namespace chrono_literals
9544684ddb6SLionel Sambuc  {
9554684ddb6SLionel Sambuc
9564684ddb6SLionel Sambuc    constexpr chrono::hours operator"" h(unsigned long long __h)
9574684ddb6SLionel Sambuc    {
9584684ddb6SLionel Sambuc        return chrono::hours(static_cast<chrono::hours::rep>(__h));
9594684ddb6SLionel Sambuc    }
9604684ddb6SLionel Sambuc
9614684ddb6SLionel Sambuc    constexpr chrono::duration<long double, ratio<3600,1>> operator"" h(long double __h)
9624684ddb6SLionel Sambuc    {
9634684ddb6SLionel Sambuc        return chrono::duration<long double, ratio<3600,1>>(__h);
9644684ddb6SLionel Sambuc    }
9654684ddb6SLionel Sambuc
9664684ddb6SLionel Sambuc
9674684ddb6SLionel Sambuc    constexpr chrono::minutes operator"" min(unsigned long long __m)
9684684ddb6SLionel Sambuc    {
9694684ddb6SLionel Sambuc        return chrono::minutes(static_cast<chrono::minutes::rep>(__m));
9704684ddb6SLionel Sambuc    }
9714684ddb6SLionel Sambuc
9724684ddb6SLionel Sambuc    constexpr chrono::duration<long double, ratio<60,1>> operator"" min(long double __m)
9734684ddb6SLionel Sambuc    {
9744684ddb6SLionel Sambuc        return chrono::duration<long double, ratio<60,1>> (__m);
9754684ddb6SLionel Sambuc    }
9764684ddb6SLionel Sambuc
9774684ddb6SLionel Sambuc
9784684ddb6SLionel Sambuc    constexpr chrono::seconds operator"" s(unsigned long long __s)
9794684ddb6SLionel Sambuc    {
9804684ddb6SLionel Sambuc        return chrono::seconds(static_cast<chrono::seconds::rep>(__s));
9814684ddb6SLionel Sambuc    }
9824684ddb6SLionel Sambuc
9834684ddb6SLionel Sambuc    constexpr chrono::duration<long double> operator"" s(long double __s)
9844684ddb6SLionel Sambuc    {
9854684ddb6SLionel Sambuc        return chrono::duration<long double> (__s);
9864684ddb6SLionel Sambuc    }
9874684ddb6SLionel Sambuc
9884684ddb6SLionel Sambuc
9894684ddb6SLionel Sambuc    constexpr chrono::milliseconds operator"" ms(unsigned long long __ms)
9904684ddb6SLionel Sambuc    {
9914684ddb6SLionel Sambuc        return chrono::milliseconds(static_cast<chrono::milliseconds::rep>(__ms));
9924684ddb6SLionel Sambuc    }
9934684ddb6SLionel Sambuc
9944684ddb6SLionel Sambuc    constexpr chrono::duration<long double, milli> operator"" ms(long double __ms)
9954684ddb6SLionel Sambuc    {
9964684ddb6SLionel Sambuc        return chrono::duration<long double, milli>(__ms);
9974684ddb6SLionel Sambuc    }
9984684ddb6SLionel Sambuc
9994684ddb6SLionel Sambuc
10004684ddb6SLionel Sambuc    constexpr chrono::microseconds operator"" us(unsigned long long __us)
10014684ddb6SLionel Sambuc    {
10024684ddb6SLionel Sambuc        return chrono::microseconds(static_cast<chrono::microseconds::rep>(__us));
10034684ddb6SLionel Sambuc    }
10044684ddb6SLionel Sambuc
10054684ddb6SLionel Sambuc    constexpr chrono::duration<long double, micro> operator"" us(long double __us)
10064684ddb6SLionel Sambuc    {
10074684ddb6SLionel Sambuc        return chrono::duration<long double, micro> (__us);
10084684ddb6SLionel Sambuc    }
10094684ddb6SLionel Sambuc
10104684ddb6SLionel Sambuc
10114684ddb6SLionel Sambuc    constexpr chrono::nanoseconds operator"" ns(unsigned long long __ns)
10124684ddb6SLionel Sambuc    {
10134684ddb6SLionel Sambuc        return chrono::nanoseconds(static_cast<chrono::nanoseconds::rep>(__ns));
10144684ddb6SLionel Sambuc    }
10154684ddb6SLionel Sambuc
10164684ddb6SLionel Sambuc    constexpr chrono::duration<long double, nano> operator"" ns(long double __ns)
10174684ddb6SLionel Sambuc    {
10184684ddb6SLionel Sambuc        return chrono::duration<long double, nano> (__ns);
10194684ddb6SLionel Sambuc    }
10204684ddb6SLionel Sambuc
10214684ddb6SLionel Sambuc}}
10224684ddb6SLionel Sambuc
10234684ddb6SLionel Sambucnamespace chrono { // hoist the literals into namespace std::chrono
10244684ddb6SLionel Sambuc   using namespace literals::chrono_literals;
10254684ddb6SLionel Sambuc}
10264684ddb6SLionel Sambuc
10274684ddb6SLionel Sambuc#endif
10284684ddb6SLionel Sambuc
10294684ddb6SLionel Sambuc_LIBCPP_END_NAMESPACE_STD
10304684ddb6SLionel Sambuc
10314684ddb6SLionel Sambuc#endif  // _LIBCPP_CHRONO
1032