chrono revision 251066
1227825Stheraven// -*- C++ -*-
2227825Stheraven//===---------------------------- chrono ----------------------------------===//
3227825Stheraven//
4227825Stheraven//                     The LLVM Compiler Infrastructure
5227825Stheraven//
6227825Stheraven// This file is dual licensed under the MIT and the University of Illinois Open
7227825Stheraven// Source Licenses. See LICENSE.TXT for details.
8227825Stheraven//
9227825Stheraven//===----------------------------------------------------------------------===//
10227825Stheraven
11227825Stheraven#ifndef _LIBCPP_CHRONO
12227825Stheraven#define _LIBCPP_CHRONO
13227825Stheraven
14227825Stheraven/*
15227825Stheraven    chrono synopsis
16227825Stheraven
17227825Stheravennamespace std
18227825Stheraven{
19227825Stheravennamespace chrono
20227825Stheraven{
21227825Stheraven
22227825Stheraventemplate <class ToDuration, class Rep, class Period>
23241903Sdimconstexpr
24227825StheravenToDuration
25227825Stheravenduration_cast(const duration<Rep, Period>& fd);
26227825Stheraven
27227825Stheraventemplate <class Rep> struct treat_as_floating_point : is_floating_point<Rep> {};
28227825Stheraven
29227825Stheraventemplate <class Rep>
30227825Stheravenstruct duration_values
31227825Stheraven{
32227825Stheravenpublic:
33241903Sdim    static constexpr Rep zero();
34241903Sdim    static constexpr Rep max();
35241903Sdim    static constexpr Rep min();
36227825Stheraven};
37227825Stheraven
38227825Stheraven// duration
39227825Stheraven
40227825Stheraventemplate <class Rep, class Period = ratio<1>>
41227825Stheravenclass duration
42227825Stheraven{
43227825Stheraven    static_assert(!__is_duration<Rep>::value, "A duration representation can not be a duration");
44227825Stheraven    static_assert(__is_ratio<Period>::value, "Second template parameter of duration must be a std::ratio");
45227825Stheraven    static_assert(Period::num > 0, "duration period must be positive");
46227825Stheravenpublic:
47227825Stheraven    typedef Rep rep;
48227825Stheraven    typedef Period period;
49227825Stheraven
50241903Sdim    constexpr duration() = default;
51227825Stheraven    template <class Rep2>
52241903Sdim        constexpr explicit duration(const Rep2& r,
53227825Stheraven            typename enable_if
54227825Stheraven            <
55227825Stheraven               is_convertible<Rep2, rep>::value &&
56227825Stheraven               (treat_as_floating_point<rep>::value ||
57227825Stheraven               !treat_as_floating_point<rep>::value && !treat_as_floating_point<Rep2>::value)
58227825Stheraven            >::type* = 0);
59227825Stheraven
60227825Stheraven    // conversions
61227825Stheraven    template <class Rep2, class Period2>
62241903Sdim        constexpr duration(const duration<Rep2, Period2>& d,
63227825Stheraven            typename enable_if
64227825Stheraven            <
65227825Stheraven                treat_as_floating_point<rep>::value ||
66227825Stheraven                ratio_divide<Period2, period>::type::den == 1
67227825Stheraven            >::type* = 0);
68227825Stheraven
69227825Stheraven    // observer
70227825Stheraven
71241903Sdim    constexpr rep count() const;
72227825Stheraven
73227825Stheraven    // arithmetic
74227825Stheraven
75241903Sdim    constexpr duration  operator+() const;
76241903Sdim    constexpr duration  operator-() const;
77227825Stheraven    duration& operator++();
78227825Stheraven    duration  operator++(int);
79227825Stheraven    duration& operator--();
80227825Stheraven    duration  operator--(int);
81227825Stheraven
82227825Stheraven    duration& operator+=(const duration& d);
83227825Stheraven    duration& operator-=(const duration& d);
84227825Stheraven
85227825Stheraven    duration& operator*=(const rep& rhs);
86227825Stheraven    duration& operator/=(const rep& rhs);
87227825Stheraven
88227825Stheraven    // special values
89227825Stheraven
90241903Sdim    static constexpr duration zero();
91241903Sdim    static constexpr duration min();
92241903Sdim    static constexpr duration max();
93227825Stheraven};
94227825Stheraven
95227825Stheraventypedef duration<long long,         nano> nanoseconds;
96227825Stheraventypedef duration<long long,        micro> microseconds;
97227825Stheraventypedef duration<long long,        milli> milliseconds;
98227825Stheraventypedef duration<long long              > seconds;
99227825Stheraventypedef duration<     long, ratio<  60> > minutes;
100227825Stheraventypedef duration<     long, ratio<3600> > hours;
101227825Stheraven
102227825Stheraventemplate <class Clock, class Duration = typename Clock::duration>
103227825Stheravenclass time_point
104227825Stheraven{
105227825Stheravenpublic:
106227825Stheraven    typedef Clock                     clock;
107227825Stheraven    typedef Duration                  duration;
108227825Stheraven    typedef typename duration::rep    rep;
109227825Stheraven    typedef typename duration::period period;
110227825Stheravenprivate:
111227825Stheraven    duration d_;  // exposition only
112227825Stheraven
113227825Stheravenpublic:
114227825Stheraven    time_point();  // has value "epoch"
115227825Stheraven    explicit time_point(const duration& d);  // same as time_point() + d
116227825Stheraven
117227825Stheraven    // conversions
118227825Stheraven    template <class Duration2>
119227825Stheraven       time_point(const time_point<clock, Duration2>& t);
120227825Stheraven
121227825Stheraven    // observer
122227825Stheraven
123227825Stheraven    duration time_since_epoch() const;
124227825Stheraven
125227825Stheraven    // arithmetic
126227825Stheraven
127227825Stheraven    time_point& operator+=(const duration& d);
128227825Stheraven    time_point& operator-=(const duration& d);
129227825Stheraven
130227825Stheraven    // special values
131227825Stheraven
132227825Stheraven    static constexpr time_point min();
133227825Stheraven    static constexpr time_point max();
134227825Stheraven};
135227825Stheraven
136227825Stheraven} // chrono
137227825Stheraven
138227825Stheraven// common_type traits
139227825Stheraventemplate <class Rep1, class Period1, class Rep2, class Period2>
140227825Stheraven  struct common_type<chrono::duration<Rep1, Period1>, chrono::duration<Rep2, Period2>>;
141227825Stheraven
142227825Stheraventemplate <class Clock, class Duration1, class Duration2>
143227825Stheraven  struct common_type<chrono::time_point<Clock, Duration1>, chrono::time_point<Clock, Duration2>>;
144227825Stheraven
145227825Stheravennamespace chrono {
146227825Stheraven
147227825Stheraven// duration arithmetic
148227825Stheraventemplate <class Rep1, class Period1, class Rep2, class Period2>
149241903Sdim  constexpr
150227825Stheraven  typename common_type<duration<Rep1, Period1>, duration<Rep2, Period2>>::type
151227825Stheraven  operator+(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
152227825Stheraventemplate <class Rep1, class Period1, class Rep2, class Period2>
153241903Sdim  constexpr
154227825Stheraven  typename common_type<duration<Rep1, Period1>, duration<Rep2, Period2>>::type
155227825Stheraven  operator-(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
156227825Stheraventemplate <class Rep1, class Period, class Rep2>
157241903Sdim  constexpr
158227825Stheraven  duration<typename common_type<Rep1, Rep2>::type, Period>
159227825Stheraven  operator*(const duration<Rep1, Period>& d, const Rep2& s);
160227825Stheraventemplate <class Rep1, class Period, class Rep2>
161241903Sdim  constexpr
162227825Stheraven  duration<typename common_type<Rep1, Rep2>::type, Period>
163227825Stheraven  operator*(const Rep1& s, const duration<Rep2, Period>& d);
164227825Stheraventemplate <class Rep1, class Period, class Rep2>
165241903Sdim  constexpr
166227825Stheraven  duration<typename common_type<Rep1, Rep2>::type, Period>
167227825Stheraven  operator/(const duration<Rep1, Period>& d, const Rep2& s);
168227825Stheraventemplate <class Rep1, class Period1, class Rep2, class Period2>
169241903Sdim  constexpr
170227825Stheraven  typename common_type<Rep1, Rep2>::type
171227825Stheraven  operator/(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
172227825Stheraven
173227825Stheraven// duration comparisons
174227825Stheraventemplate <class Rep1, class Period1, class Rep2, class Period2>
175241903Sdim   constexpr
176227825Stheraven   bool operator==(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
177227825Stheraventemplate <class Rep1, class Period1, class Rep2, class Period2>
178241903Sdim   constexpr
179227825Stheraven   bool operator!=(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
180227825Stheraventemplate <class Rep1, class Period1, class Rep2, class Period2>
181241903Sdim   constexpr
182227825Stheraven   bool operator< (const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
183227825Stheraventemplate <class Rep1, class Period1, class Rep2, class Period2>
184241903Sdim   constexpr
185227825Stheraven   bool operator<=(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
186227825Stheraventemplate <class Rep1, class Period1, class Rep2, class Period2>
187241903Sdim   constexpr
188227825Stheraven   bool operator> (const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
189227825Stheraventemplate <class Rep1, class Period1, class Rep2, class Period2>
190241903Sdim   constexpr
191227825Stheraven   bool operator>=(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
192227825Stheraven
193227825Stheraven// duration_cast
194227825Stheraventemplate <class ToDuration, class Rep, class Period>
195227825Stheraven  ToDuration duration_cast(const duration<Rep, Period>& d);
196227825Stheraven
197227825Stheraven// time_point arithmetic
198227825Stheraventemplate <class Clock, class Duration1, class Rep2, class Period2>
199227825Stheraven  time_point<Clock, typename common_type<Duration1, duration<Rep2, Period2>>::type>
200227825Stheraven  operator+(const time_point<Clock, Duration1>& lhs, const duration<Rep2, Period2>& rhs);
201227825Stheraventemplate <class Rep1, class Period1, class Clock, class Duration2>
202227825Stheraven  time_point<Clock, typename common_type<duration<Rep1, Period1>, Duration2>::type>
203227825Stheraven  operator+(const duration<Rep1, Period1>& lhs, const time_point<Clock, Duration2>& rhs);
204227825Stheraventemplate <class Clock, class Duration1, class Rep2, class Period2>
205227825Stheraven  time_point<Clock, typename common_type<Duration1, duration<Rep2, Period2>>::type>
206227825Stheraven  operator-(const time_point<Clock, Duration1>& lhs, const duration<Rep2, Period2>& rhs);
207227825Stheraventemplate <class Clock, class Duration1, class Duration2>
208227825Stheraven  typename common_type<Duration1, Duration2>::type
209227825Stheraven  operator-(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
210227825Stheraven
211227825Stheraven// time_point comparisons
212227825Stheraventemplate <class Clock, class Duration1, class Duration2>
213227825Stheraven   bool operator==(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
214227825Stheraventemplate <class Clock, class Duration1, class Duration2>
215227825Stheraven   bool operator!=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
216227825Stheraventemplate <class Clock, class Duration1, class Duration2>
217227825Stheraven   bool operator< (const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
218227825Stheraventemplate <class Clock, class Duration1, class Duration2>
219227825Stheraven   bool operator<=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
220227825Stheraventemplate <class Clock, class Duration1, class Duration2>
221227825Stheraven   bool operator> (const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
222227825Stheraventemplate <class Clock, class Duration1, class Duration2>
223227825Stheraven   bool operator>=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
224227825Stheraven
225227825Stheraven// time_point_cast
226227825Stheraven
227227825Stheraventemplate <class ToDuration, class Clock, class Duration>
228227825Stheraven  time_point<Clock, ToDuration> time_point_cast(const time_point<Clock, Duration>& t);
229227825Stheraven
230227825Stheraven// Clocks
231227825Stheraven
232227825Stheravenclass system_clock
233227825Stheraven{
234227825Stheravenpublic:
235227825Stheraven    typedef microseconds                     duration;
236227825Stheraven    typedef duration::rep                    rep;
237227825Stheraven    typedef duration::period                 period;
238227825Stheraven    typedef chrono::time_point<system_clock> time_point;
239227825Stheraven    static const bool is_steady =            false;
240227825Stheraven
241227825Stheraven    static time_point now() noexcept;
242227825Stheraven    static time_t     to_time_t  (const time_point& __t) noexcept;
243227825Stheraven    static time_point from_time_t(time_t __t) noexcept;
244227825Stheraven};
245227825Stheraven
246227825Stheravenclass steady_clock
247227825Stheraven{
248227825Stheravenpublic:
249227825Stheraven    typedef nanoseconds                                   duration;
250227825Stheraven    typedef duration::rep                                 rep;
251227825Stheraven    typedef duration::period                              period;
252227825Stheraven    typedef chrono::time_point<steady_clock, duration>    time_point;
253227825Stheraven    static const bool is_steady =                         true;
254227825Stheraven
255227825Stheraven    static time_point now() noexcept;
256227825Stheraven};
257227825Stheraven
258227825Stheraventypedef steady_clock high_resolution_clock;
259227825Stheraven
260227825Stheraven}  // chrono
261227825Stheraven
262227825Stheraven}  // std
263227825Stheraven*/
264227825Stheraven
265227825Stheraven#include <__config>
266227825Stheraven#include <ctime>
267227825Stheraven#include <type_traits>
268227825Stheraven#include <ratio>
269227825Stheraven#include <limits>
270227825Stheraven
271232950Stheraven#include <__undef_min_max>
272232950Stheraven
273227825Stheraven#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
274227825Stheraven#pragma GCC system_header
275227825Stheraven#endif
276227825Stheraven
277227825Stheraven_LIBCPP_BEGIN_NAMESPACE_STD
278227825Stheraven
279227825Stheravennamespace chrono
280227825Stheraven{
281227825Stheraven
282249998Sdimtemplate <class _Rep, class _Period = ratio<1> > class _LIBCPP_TYPE_VIS duration;
283227825Stheraven
284227825Stheraventemplate <class _Tp>
285227825Stheravenstruct __is_duration : false_type {};
286227825Stheraven
287227825Stheraventemplate <class _Rep, class _Period>
288227825Stheravenstruct __is_duration<duration<_Rep, _Period> > : true_type  {};
289227825Stheraven
290227825Stheraventemplate <class _Rep, class _Period>
291227825Stheravenstruct __is_duration<const duration<_Rep, _Period> > : true_type  {};
292227825Stheraven
293227825Stheraventemplate <class _Rep, class _Period>
294227825Stheravenstruct __is_duration<volatile duration<_Rep, _Period> > : true_type  {};
295227825Stheraven
296227825Stheraventemplate <class _Rep, class _Period>
297227825Stheravenstruct __is_duration<const volatile duration<_Rep, _Period> > : true_type  {};
298227825Stheraven
299227825Stheraven} // chrono
300227825Stheraven
301227825Stheraventemplate <class _Rep1, class _Period1, class _Rep2, class _Period2>
302249998Sdimstruct _LIBCPP_TYPE_VIS common_type<chrono::duration<_Rep1, _Period1>,
303227825Stheraven                                   chrono::duration<_Rep2, _Period2> >
304227825Stheraven{
305227825Stheraven    typedef chrono::duration<typename common_type<_Rep1, _Rep2>::type,
306227825Stheraven                             typename __ratio_gcd<_Period1, _Period2>::type> type;
307227825Stheraven};
308227825Stheraven
309227825Stheravennamespace chrono {
310227825Stheraven
311227825Stheraven// duration_cast
312227825Stheraven
313227825Stheraventemplate <class _FromDuration, class _ToDuration,
314227825Stheraven          class _Period = typename ratio_divide<typename _FromDuration::period, typename _ToDuration::period>::type,
315227825Stheraven          bool = _Period::num == 1,
316227825Stheraven          bool = _Period::den == 1>
317227825Stheravenstruct __duration_cast;
318227825Stheraven
319227825Stheraventemplate <class _FromDuration, class _ToDuration, class _Period>
320227825Stheravenstruct __duration_cast<_FromDuration, _ToDuration, _Period, true, true>
321227825Stheraven{
322241903Sdim    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
323227825Stheraven    _ToDuration operator()(const _FromDuration& __fd) const
324227825Stheraven    {
325227825Stheraven        return _ToDuration(static_cast<typename _ToDuration::rep>(__fd.count()));
326227825Stheraven    }
327227825Stheraven};
328227825Stheraven
329227825Stheraventemplate <class _FromDuration, class _ToDuration, class _Period>
330227825Stheravenstruct __duration_cast<_FromDuration, _ToDuration, _Period, true, false>
331227825Stheraven{
332241903Sdim    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
333227825Stheraven    _ToDuration operator()(const _FromDuration& __fd) const
334227825Stheraven    {
335227825Stheraven        typedef typename common_type<typename _ToDuration::rep, typename _FromDuration::rep, intmax_t>::type _Ct;
336227825Stheraven        return _ToDuration(static_cast<typename _ToDuration::rep>(
337227825Stheraven                           static_cast<_Ct>(__fd.count()) / static_cast<_Ct>(_Period::den)));
338227825Stheraven    }
339227825Stheraven};
340227825Stheraven
341227825Stheraventemplate <class _FromDuration, class _ToDuration, class _Period>
342227825Stheravenstruct __duration_cast<_FromDuration, _ToDuration, _Period, false, true>
343227825Stheraven{
344241903Sdim    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
345227825Stheraven    _ToDuration operator()(const _FromDuration& __fd) const
346227825Stheraven    {
347227825Stheraven        typedef typename common_type<typename _ToDuration::rep, typename _FromDuration::rep, intmax_t>::type _Ct;
348227825Stheraven        return _ToDuration(static_cast<typename _ToDuration::rep>(
349227825Stheraven                           static_cast<_Ct>(__fd.count()) * static_cast<_Ct>(_Period::num)));
350227825Stheraven    }
351227825Stheraven};
352227825Stheraven
353227825Stheraventemplate <class _FromDuration, class _ToDuration, class _Period>
354227825Stheravenstruct __duration_cast<_FromDuration, _ToDuration, _Period, false, false>
355227825Stheraven{
356241903Sdim    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
357227825Stheraven    _ToDuration operator()(const _FromDuration& __fd) const
358227825Stheraven    {
359227825Stheraven        typedef typename common_type<typename _ToDuration::rep, typename _FromDuration::rep, intmax_t>::type _Ct;
360227825Stheraven        return _ToDuration(static_cast<typename _ToDuration::rep>(
361227825Stheraven                           static_cast<_Ct>(__fd.count()) * static_cast<_Ct>(_Period::num)
362227825Stheraven                                                          / static_cast<_Ct>(_Period::den)));
363227825Stheraven    }
364227825Stheraven};
365227825Stheraven
366227825Stheraventemplate <class _ToDuration, class _Rep, class _Period>
367227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
368241903Sdim_LIBCPP_CONSTEXPR
369227825Stheraventypename enable_if
370227825Stheraven<
371227825Stheraven    __is_duration<_ToDuration>::value,
372227825Stheraven    _ToDuration
373227825Stheraven>::type
374227825Stheravenduration_cast(const duration<_Rep, _Period>& __fd)
375227825Stheraven{
376227825Stheraven    return __duration_cast<duration<_Rep, _Period>, _ToDuration>()(__fd);
377227825Stheraven}
378227825Stheraven
379227825Stheraventemplate <class _Rep>
380249998Sdimstruct _LIBCPP_TYPE_VIS treat_as_floating_point : is_floating_point<_Rep> {};
381227825Stheraven
382227825Stheraventemplate <class _Rep>
383249998Sdimstruct _LIBCPP_TYPE_VIS duration_values
384227825Stheraven{
385227825Stheravenpublic:
386241903Sdim    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR _Rep zero() {return _Rep(0);}
387241903Sdim    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR _Rep max()  {return numeric_limits<_Rep>::max();}
388241903Sdim    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR _Rep min()  {return numeric_limits<_Rep>::lowest();}
389227825Stheraven};
390227825Stheraven
391227825Stheraven// duration
392227825Stheraven
393227825Stheraventemplate <class _Rep, class _Period>
394249998Sdimclass _LIBCPP_TYPE_VIS duration
395227825Stheraven{
396227825Stheraven    static_assert(!__is_duration<_Rep>::value, "A duration representation can not be a duration");
397227825Stheraven    static_assert(__is_ratio<_Period>::value, "Second template parameter of duration must be a std::ratio");
398227825Stheraven    static_assert(_Period::num > 0, "duration period must be positive");
399227825Stheravenpublic:
400227825Stheraven    typedef _Rep rep;
401227825Stheraven    typedef _Period period;
402227825Stheravenprivate:
403227825Stheraven    rep __rep_;
404227825Stheravenpublic:
405227825Stheraven
406241903Sdim    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR duration() {} // = default;
407227825Stheraven    template <class _Rep2>
408241903Sdim        _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
409227825Stheraven        explicit duration(const _Rep2& __r,
410227825Stheraven            typename enable_if
411227825Stheraven            <
412227825Stheraven               is_convertible<_Rep2, rep>::value &&
413227825Stheraven               (treat_as_floating_point<rep>::value ||
414227825Stheraven               !treat_as_floating_point<_Rep2>::value)
415227825Stheraven            >::type* = 0)
416227825Stheraven                : __rep_(__r) {}
417227825Stheraven
418227825Stheraven    // conversions
419227825Stheraven    template <class _Rep2, class _Period2>
420241903Sdim        _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
421227825Stheraven        duration(const duration<_Rep2, _Period2>& __d,
422227825Stheraven            typename enable_if
423227825Stheraven            <
424227825Stheraven                treat_as_floating_point<rep>::value ||
425227825Stheraven                (ratio_divide<_Period2, period>::type::den == 1 &&
426227825Stheraven                 !treat_as_floating_point<_Rep2>::value)
427227825Stheraven            >::type* = 0)
428227825Stheraven                : __rep_(_VSTD::chrono::duration_cast<duration>(__d).count()) {}
429227825Stheraven
430227825Stheraven    // observer
431227825Stheraven
432241903Sdim    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR rep count() const {return __rep_;}
433227825Stheraven
434227825Stheraven    // arithmetic
435227825Stheraven
436241903Sdim    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR duration  operator+() const {return *this;}
437241903Sdim    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR duration  operator-() const {return duration(-__rep_);}
438227825Stheraven    _LIBCPP_INLINE_VISIBILITY duration& operator++()      {++__rep_; return *this;}
439227825Stheraven    _LIBCPP_INLINE_VISIBILITY duration  operator++(int)   {return duration(__rep_++);}
440227825Stheraven    _LIBCPP_INLINE_VISIBILITY duration& operator--()      {--__rep_; return *this;}
441227825Stheraven    _LIBCPP_INLINE_VISIBILITY duration  operator--(int)   {return duration(__rep_--);}
442227825Stheraven
443227825Stheraven    _LIBCPP_INLINE_VISIBILITY duration& operator+=(const duration& __d) {__rep_ += __d.count(); return *this;}
444227825Stheraven    _LIBCPP_INLINE_VISIBILITY duration& operator-=(const duration& __d) {__rep_ -= __d.count(); return *this;}
445227825Stheraven
446227825Stheraven    _LIBCPP_INLINE_VISIBILITY duration& operator*=(const rep& rhs) {__rep_ *= rhs; return *this;}
447227825Stheraven    _LIBCPP_INLINE_VISIBILITY duration& operator/=(const rep& rhs) {__rep_ /= rhs; return *this;}
448227825Stheraven    _LIBCPP_INLINE_VISIBILITY duration& operator%=(const rep& rhs) {__rep_ %= rhs; return *this;}
449227825Stheraven    _LIBCPP_INLINE_VISIBILITY duration& operator%=(const duration& rhs) {__rep_ %= rhs.count(); return *this;}
450227825Stheraven
451227825Stheraven    // special values
452227825Stheraven
453241903Sdim    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR duration zero() {return duration(duration_values<rep>::zero());}
454241903Sdim    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR duration min()  {return duration(duration_values<rep>::min());}
455241903Sdim    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR duration max()  {return duration(duration_values<rep>::max());}
456227825Stheraven};
457227825Stheraven
458227825Stheraventypedef duration<long long,         nano> nanoseconds;
459227825Stheraventypedef duration<long long,        micro> microseconds;
460227825Stheraventypedef duration<long long,        milli> milliseconds;
461227825Stheraventypedef duration<long long              > seconds;
462227825Stheraventypedef duration<     long, ratio<  60> > minutes;
463227825Stheraventypedef duration<     long, ratio<3600> > hours;
464227825Stheraven
465227825Stheraven// Duration ==
466227825Stheraven
467227825Stheraventemplate <class _LhsDuration, class _RhsDuration>
468227825Stheravenstruct __duration_eq
469227825Stheraven{
470241903Sdim    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
471251066Sdim    bool operator()(const _LhsDuration& __lhs, const _RhsDuration& __rhs) const
472227825Stheraven        {
473227825Stheraven            typedef typename common_type<_LhsDuration, _RhsDuration>::type _Ct;
474227825Stheraven            return _Ct(__lhs).count() == _Ct(__rhs).count();
475227825Stheraven        }
476227825Stheraven};
477227825Stheraven
478227825Stheraventemplate <class _LhsDuration>
479227825Stheravenstruct __duration_eq<_LhsDuration, _LhsDuration>
480227825Stheraven{
481241903Sdim    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
482251066Sdim    bool operator()(const _LhsDuration& __lhs, const _LhsDuration& __rhs) const
483227825Stheraven        {return __lhs.count() == __rhs.count();}
484227825Stheraven};
485227825Stheraven
486227825Stheraventemplate <class _Rep1, class _Period1, class _Rep2, class _Period2>
487227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
488241903Sdim_LIBCPP_CONSTEXPR
489227825Stheravenbool
490227825Stheravenoperator==(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
491227825Stheraven{
492227825Stheraven    return __duration_eq<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >()(__lhs, __rhs);
493227825Stheraven}
494227825Stheraven
495227825Stheraven// Duration !=
496227825Stheraven
497227825Stheraventemplate <class _Rep1, class _Period1, class _Rep2, class _Period2>
498227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
499241903Sdim_LIBCPP_CONSTEXPR
500227825Stheravenbool
501227825Stheravenoperator!=(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
502227825Stheraven{
503227825Stheraven    return !(__lhs == __rhs);
504227825Stheraven}
505227825Stheraven
506227825Stheraven// Duration <
507227825Stheraven
508227825Stheraventemplate <class _LhsDuration, class _RhsDuration>
509227825Stheravenstruct __duration_lt
510227825Stheraven{
511241903Sdim    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
512251066Sdim    bool operator()(const _LhsDuration& __lhs, const _RhsDuration& __rhs) const
513227825Stheraven        {
514227825Stheraven            typedef typename common_type<_LhsDuration, _RhsDuration>::type _Ct;
515227825Stheraven            return _Ct(__lhs).count() < _Ct(__rhs).count();
516227825Stheraven        }
517227825Stheraven};
518227825Stheraven
519227825Stheraventemplate <class _LhsDuration>
520227825Stheravenstruct __duration_lt<_LhsDuration, _LhsDuration>
521227825Stheraven{
522241903Sdim    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
523251066Sdim    bool operator()(const _LhsDuration& __lhs, const _LhsDuration& __rhs) const
524227825Stheraven        {return __lhs.count() < __rhs.count();}
525227825Stheraven};
526227825Stheraven
527227825Stheraventemplate <class _Rep1, class _Period1, class _Rep2, class _Period2>
528227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
529241903Sdim_LIBCPP_CONSTEXPR
530227825Stheravenbool
531227825Stheravenoperator< (const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
532227825Stheraven{
533227825Stheraven    return __duration_lt<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >()(__lhs, __rhs);
534227825Stheraven}
535227825Stheraven
536227825Stheraven// Duration >
537227825Stheraven
538227825Stheraventemplate <class _Rep1, class _Period1, class _Rep2, class _Period2>
539227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
540241903Sdim_LIBCPP_CONSTEXPR
541227825Stheravenbool
542227825Stheravenoperator> (const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
543227825Stheraven{
544227825Stheraven    return __rhs < __lhs;
545227825Stheraven}
546227825Stheraven
547227825Stheraven// Duration <=
548227825Stheraven
549227825Stheraventemplate <class _Rep1, class _Period1, class _Rep2, class _Period2>
550227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
551241903Sdim_LIBCPP_CONSTEXPR
552227825Stheravenbool
553227825Stheravenoperator<=(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
554227825Stheraven{
555227825Stheraven    return !(__rhs < __lhs);
556227825Stheraven}
557227825Stheraven
558227825Stheraven// Duration >=
559227825Stheraven
560227825Stheraventemplate <class _Rep1, class _Period1, class _Rep2, class _Period2>
561227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
562241903Sdim_LIBCPP_CONSTEXPR
563227825Stheravenbool
564227825Stheravenoperator>=(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
565227825Stheraven{
566227825Stheraven    return !(__lhs < __rhs);
567227825Stheraven}
568227825Stheraven
569227825Stheraven// Duration +
570227825Stheraven
571227825Stheraventemplate <class _Rep1, class _Period1, class _Rep2, class _Period2>
572227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
573241903Sdim_LIBCPP_CONSTEXPR
574227825Stheraventypename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type
575227825Stheravenoperator+(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
576227825Stheraven{
577241903Sdim    typedef typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type _Cd;
578241903Sdim    return _Cd(_Cd(__lhs).count() + _Cd(__rhs).count());
579227825Stheraven}
580227825Stheraven
581227825Stheraven// Duration -
582227825Stheraven
583227825Stheraventemplate <class _Rep1, class _Period1, class _Rep2, class _Period2>
584227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
585241903Sdim_LIBCPP_CONSTEXPR
586227825Stheraventypename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type
587227825Stheravenoperator-(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
588227825Stheraven{
589241903Sdim    typedef typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type _Cd;
590241903Sdim    return _Cd(_Cd(__lhs).count() - _Cd(__rhs).count());
591227825Stheraven}
592227825Stheraven
593227825Stheraven// Duration *
594227825Stheraven
595227825Stheraventemplate <class _Rep1, class _Period, class _Rep2>
596227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
597241903Sdim_LIBCPP_CONSTEXPR
598227825Stheraventypename enable_if
599227825Stheraven<
600227825Stheraven    is_convertible<_Rep2, typename common_type<_Rep1, _Rep2>::type>::value,
601227825Stheraven    duration<typename common_type<_Rep1, _Rep2>::type, _Period>
602227825Stheraven>::type
603227825Stheravenoperator*(const duration<_Rep1, _Period>& __d, const _Rep2& __s)
604227825Stheraven{
605227825Stheraven    typedef typename common_type<_Rep1, _Rep2>::type _Cr;
606241903Sdim    typedef duration<_Cr, _Period> _Cd;
607241903Sdim    return _Cd(_Cd(__d).count() * static_cast<_Cr>(__s));
608227825Stheraven}
609227825Stheraven
610227825Stheraventemplate <class _Rep1, class _Period, class _Rep2>
611227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
612241903Sdim_LIBCPP_CONSTEXPR
613227825Stheraventypename enable_if
614227825Stheraven<
615227825Stheraven    is_convertible<_Rep1, typename common_type<_Rep1, _Rep2>::type>::value,
616227825Stheraven    duration<typename common_type<_Rep1, _Rep2>::type, _Period>
617227825Stheraven>::type
618227825Stheravenoperator*(const _Rep1& __s, const duration<_Rep2, _Period>& __d)
619227825Stheraven{
620227825Stheraven    return __d * __s;
621227825Stheraven}
622227825Stheraven
623227825Stheraven// Duration /
624227825Stheraven
625227825Stheraventemplate <class _Duration, class _Rep, bool = __is_duration<_Rep>::value>
626227825Stheravenstruct __duration_divide_result
627227825Stheraven{
628227825Stheraven};
629227825Stheraven
630227825Stheraventemplate <class _Duration, class _Rep2,
631227825Stheraven    bool = is_convertible<_Rep2,
632227825Stheraven                          typename common_type<typename _Duration::rep, _Rep2>::type>::value>
633227825Stheravenstruct __duration_divide_imp
634227825Stheraven{
635227825Stheraven};
636227825Stheraven
637227825Stheraventemplate <class _Rep1, class _Period, class _Rep2>
638227825Stheravenstruct __duration_divide_imp<duration<_Rep1, _Period>, _Rep2, true>
639227825Stheraven{
640227825Stheraven    typedef duration<typename common_type<_Rep1, _Rep2>::type, _Period> type;
641227825Stheraven};
642227825Stheraven
643227825Stheraventemplate <class _Rep1, class _Period, class _Rep2>
644227825Stheravenstruct __duration_divide_result<duration<_Rep1, _Period>, _Rep2, false>
645227825Stheraven    : __duration_divide_imp<duration<_Rep1, _Period>, _Rep2>
646227825Stheraven{
647227825Stheraven};
648227825Stheraven
649227825Stheraventemplate <class _Rep1, class _Period, class _Rep2>
650227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
651241903Sdim_LIBCPP_CONSTEXPR
652227825Stheraventypename __duration_divide_result<duration<_Rep1, _Period>, _Rep2>::type
653227825Stheravenoperator/(const duration<_Rep1, _Period>& __d, const _Rep2& __s)
654227825Stheraven{
655227825Stheraven    typedef typename common_type<_Rep1, _Rep2>::type _Cr;
656241903Sdim    typedef duration<_Cr, _Period> _Cd;
657241903Sdim    return _Cd(_Cd(__d).count() / static_cast<_Cr>(__s));
658227825Stheraven}
659227825Stheraven
660227825Stheraventemplate <class _Rep1, class _Period1, class _Rep2, class _Period2>
661227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
662241903Sdim_LIBCPP_CONSTEXPR
663227825Stheraventypename common_type<_Rep1, _Rep2>::type
664227825Stheravenoperator/(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
665227825Stheraven{
666227825Stheraven    typedef typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type _Ct;
667227825Stheraven    return _Ct(__lhs).count() / _Ct(__rhs).count();
668227825Stheraven}
669227825Stheraven
670227825Stheraven// Duration %
671227825Stheraven
672227825Stheraventemplate <class _Rep1, class _Period, class _Rep2>
673227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
674241903Sdim_LIBCPP_CONSTEXPR
675227825Stheraventypename __duration_divide_result<duration<_Rep1, _Period>, _Rep2>::type
676227825Stheravenoperator%(const duration<_Rep1, _Period>& __d, const _Rep2& __s)
677227825Stheraven{
678227825Stheraven    typedef typename common_type<_Rep1, _Rep2>::type _Cr;
679241903Sdim    typedef duration<_Cr, _Period> _Cd;
680241903Sdim    return _Cd(_Cd(__d).count() % static_cast<_Cr>(__s));
681227825Stheraven}
682227825Stheraven
683227825Stheraventemplate <class _Rep1, class _Period1, class _Rep2, class _Period2>
684227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
685241903Sdim_LIBCPP_CONSTEXPR
686227825Stheraventypename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type
687227825Stheravenoperator%(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
688227825Stheraven{
689241903Sdim    typedef typename common_type<_Rep1, _Rep2>::type _Cr;
690241903Sdim    typedef typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type _Cd;
691241903Sdim    return _Cd(static_cast<_Cr>(_Cd(__lhs).count()) % static_cast<_Cr>(_Cd(__rhs).count()));
692227825Stheraven}
693227825Stheraven
694227825Stheraven//////////////////////////////////////////////////////////
695227825Stheraven///////////////////// time_point /////////////////////////
696227825Stheraven//////////////////////////////////////////////////////////
697227825Stheraven
698227825Stheraventemplate <class _Clock, class _Duration = typename _Clock::duration>
699249998Sdimclass _LIBCPP_TYPE_VIS time_point
700227825Stheraven{
701227825Stheraven    static_assert(__is_duration<_Duration>::value,
702227825Stheraven                  "Second template parameter of time_point must be a std::chrono::duration");
703227825Stheravenpublic:
704227825Stheraven    typedef _Clock                    clock;
705227825Stheraven    typedef _Duration                 duration;
706227825Stheraven    typedef typename duration::rep    rep;
707227825Stheraven    typedef typename duration::period period;
708227825Stheravenprivate:
709227825Stheraven    duration __d_;
710227825Stheraven
711227825Stheravenpublic:
712227825Stheraven    _LIBCPP_INLINE_VISIBILITY time_point() : __d_(duration::zero()) {}
713227825Stheraven    _LIBCPP_INLINE_VISIBILITY explicit time_point(const duration& __d) : __d_(__d) {}
714227825Stheraven
715227825Stheraven    // conversions
716227825Stheraven    template <class _Duration2>
717227825Stheraven    _LIBCPP_INLINE_VISIBILITY
718227825Stheraven    time_point(const time_point<clock, _Duration2>& t,
719227825Stheraven        typename enable_if
720227825Stheraven        <
721227825Stheraven            is_convertible<_Duration2, duration>::value
722227825Stheraven        >::type* = 0)
723227825Stheraven            : __d_(t.time_since_epoch()) {}
724227825Stheraven
725227825Stheraven    // observer
726227825Stheraven
727227825Stheraven    _LIBCPP_INLINE_VISIBILITY duration time_since_epoch() const {return __d_;}
728227825Stheraven
729227825Stheraven    // arithmetic
730227825Stheraven
731241903Sdim	_LIBCPP_INLINE_VISIBILITY time_point& operator+=(const duration& __d) {__d_ += __d; return *this;}
732241903Sdim	_LIBCPP_INLINE_VISIBILITY time_point& operator-=(const duration& __d) {__d_ -= __d; return *this;}
733227825Stheraven
734227825Stheraven    // special values
735227825Stheraven
736241903Sdim    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR time_point min() {return time_point(duration::min());}
737241903Sdim    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR time_point max() {return time_point(duration::max());}
738227825Stheraven};
739227825Stheraven
740227825Stheraven} // chrono
741227825Stheraven
742227825Stheraventemplate <class _Clock, class _Duration1, class _Duration2>
743249998Sdimstruct _LIBCPP_TYPE_VIS common_type<chrono::time_point<_Clock, _Duration1>,
744227825Stheraven                                   chrono::time_point<_Clock, _Duration2> >
745227825Stheraven{
746227825Stheraven    typedef chrono::time_point<_Clock, typename common_type<_Duration1, _Duration2>::type> type;
747227825Stheraven};
748227825Stheraven
749227825Stheravennamespace chrono {
750227825Stheraven
751227825Stheraventemplate <class _ToDuration, class _Clock, class _Duration>
752227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
753227825Stheraventime_point<_Clock, _ToDuration>
754227825Stheraventime_point_cast(const time_point<_Clock, _Duration>& __t)
755227825Stheraven{
756227825Stheraven    return time_point<_Clock, _ToDuration>(_VSTD::chrono::duration_cast<_ToDuration>(__t.time_since_epoch()));
757227825Stheraven}
758227825Stheraven
759227825Stheraven// time_point ==
760227825Stheraven
761227825Stheraventemplate <class _Clock, class _Duration1, class _Duration2>
762227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
763227825Stheravenbool
764227825Stheravenoperator==(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
765227825Stheraven{
766227825Stheraven    return __lhs.time_since_epoch() == __rhs.time_since_epoch();
767227825Stheraven}
768227825Stheraven
769227825Stheraven// time_point !=
770227825Stheraven
771227825Stheraventemplate <class _Clock, class _Duration1, class _Duration2>
772227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
773227825Stheravenbool
774227825Stheravenoperator!=(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
775227825Stheraven{
776227825Stheraven    return !(__lhs == __rhs);
777227825Stheraven}
778227825Stheraven
779227825Stheraven// time_point <
780227825Stheraven
781227825Stheraventemplate <class _Clock, class _Duration1, class _Duration2>
782227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
783227825Stheravenbool
784227825Stheravenoperator<(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
785227825Stheraven{
786227825Stheraven    return __lhs.time_since_epoch() < __rhs.time_since_epoch();
787227825Stheraven}
788227825Stheraven
789227825Stheraven// time_point >
790227825Stheraven
791227825Stheraventemplate <class _Clock, class _Duration1, class _Duration2>
792227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
793227825Stheravenbool
794227825Stheravenoperator>(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
795227825Stheraven{
796227825Stheraven    return __rhs < __lhs;
797227825Stheraven}
798227825Stheraven
799227825Stheraven// time_point <=
800227825Stheraven
801227825Stheraventemplate <class _Clock, class _Duration1, class _Duration2>
802227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
803227825Stheravenbool
804227825Stheravenoperator<=(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
805227825Stheraven{
806227825Stheraven    return !(__rhs < __lhs);
807227825Stheraven}
808227825Stheraven
809227825Stheraven// time_point >=
810227825Stheraven
811227825Stheraventemplate <class _Clock, class _Duration1, class _Duration2>
812227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
813227825Stheravenbool
814227825Stheravenoperator>=(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
815227825Stheraven{
816227825Stheraven    return !(__lhs < __rhs);
817227825Stheraven}
818227825Stheraven
819227825Stheraven// time_point operator+(time_point x, duration y);
820227825Stheraven
821227825Stheraventemplate <class _Clock, class _Duration1, class _Rep2, class _Period2>
822227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
823227825Stheraventime_point<_Clock, typename common_type<_Duration1, duration<_Rep2, _Period2> >::type>
824227825Stheravenoperator+(const time_point<_Clock, _Duration1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
825227825Stheraven{
826227825Stheraven    typedef time_point<_Clock, typename common_type<_Duration1, duration<_Rep2, _Period2> >::type> _Tr;
827227825Stheraven    _Tr __r(__lhs.time_since_epoch());
828227825Stheraven    __r += __rhs;
829227825Stheraven    return __r;
830227825Stheraven}
831227825Stheraven
832227825Stheraven// time_point operator+(duration x, time_point y);
833227825Stheraven
834227825Stheraventemplate <class _Rep1, class _Period1, class _Clock, class _Duration2>
835227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
836227825Stheraventime_point<_Clock, typename common_type<duration<_Rep1, _Period1>, _Duration2>::type>
837227825Stheravenoperator+(const duration<_Rep1, _Period1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
838227825Stheraven{
839227825Stheraven    return __rhs + __lhs;
840227825Stheraven}
841227825Stheraven
842227825Stheraven// time_point operator-(time_point x, duration y);
843227825Stheraven
844227825Stheraventemplate <class _Clock, class _Duration1, class _Rep2, class _Period2>
845227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
846227825Stheraventime_point<_Clock, typename common_type<_Duration1, duration<_Rep2, _Period2> >::type>
847227825Stheravenoperator-(const time_point<_Clock, _Duration1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
848227825Stheraven{
849227825Stheraven    return __lhs + (-__rhs);
850227825Stheraven}
851227825Stheraven
852227825Stheraven// duration operator-(time_point x, time_point y);
853227825Stheraven
854227825Stheraventemplate <class _Clock, class _Duration1, class _Duration2>
855227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
856227825Stheraventypename common_type<_Duration1, _Duration2>::type
857227825Stheravenoperator-(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
858227825Stheraven{
859227825Stheraven    return __lhs.time_since_epoch() - __rhs.time_since_epoch();
860227825Stheraven}
861227825Stheraven
862227825Stheraven//////////////////////////////////////////////////////////
863227825Stheraven/////////////////////// clocks ///////////////////////////
864227825Stheraven//////////////////////////////////////////////////////////
865227825Stheraven
866249998Sdimclass _LIBCPP_TYPE_VIS system_clock
867227825Stheraven{
868227825Stheravenpublic:
869227825Stheraven    typedef microseconds                     duration;
870227825Stheraven    typedef duration::rep                    rep;
871227825Stheraven    typedef duration::period                 period;
872227825Stheraven    typedef chrono::time_point<system_clock> time_point;
873227825Stheraven    static const bool is_steady =            false;
874227825Stheraven
875227825Stheraven    static time_point now() _NOEXCEPT;
876227825Stheraven    static time_t     to_time_t  (const time_point& __t) _NOEXCEPT;
877227825Stheraven    static time_point from_time_t(time_t __t) _NOEXCEPT;
878227825Stheraven};
879227825Stheraven
880249998Sdimclass _LIBCPP_TYPE_VIS steady_clock
881227825Stheraven{
882227825Stheravenpublic:
883227825Stheraven    typedef nanoseconds                                   duration;
884227825Stheraven    typedef duration::rep                                 rep;
885227825Stheraven    typedef duration::period                              period;
886227825Stheraven    typedef chrono::time_point<steady_clock, duration>    time_point;
887227825Stheraven    static const bool is_steady =                         true;
888227825Stheraven
889227825Stheraven    static time_point now() _NOEXCEPT;
890227825Stheraven};
891227825Stheraven
892227825Stheraventypedef steady_clock high_resolution_clock;
893227825Stheraven
894227825Stheraven} // chrono
895227825Stheraven
896227825Stheraven_LIBCPP_END_NAMESPACE_STD
897227825Stheraven
898227825Stheraven#endif  // _LIBCPP_CHRONO
899