N3191: C++ Timeout Specification
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@119909 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
		| @@ -383,9 +383,9 @@ condition_variable::wait_for(unique_lock<mutex>& __lk, | |||||||
| { | { | ||||||
|     using namespace chrono; |     using namespace chrono; | ||||||
|     system_clock::time_point __s_now = system_clock::now(); |     system_clock::time_point __s_now = system_clock::now(); | ||||||
|     monotonic_clock::time_point  __c_now = monotonic_clock::now(); |     steady_clock::time_point __c_now = steady_clock::now(); | ||||||
|     __do_timed_wait(__lk, __s_now + __ceil<nanoseconds>(__d)); |     __do_timed_wait(__lk, __s_now + __ceil<nanoseconds>(__d)); | ||||||
|     return monotonic_clock::now() - __c_now < __d ? cv_status::no_timeout : |     return steady_clock::now() - __c_now < __d ? cv_status::no_timeout : | ||||||
|                                                  cv_status::timeout; |                                                  cv_status::timeout; | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -396,7 +396,7 @@ condition_variable::wait_for(unique_lock<mutex>& __lk, | |||||||
|                              const chrono::duration<_Rep, _Period>& __d, |                              const chrono::duration<_Rep, _Period>& __d, | ||||||
|                              _Predicate __pred) |                              _Predicate __pred) | ||||||
| { | { | ||||||
|     return wait_until(__lk, chrono::monotonic_clock::now() + __d, |     return wait_until(__lk, chrono::steady_clock::now() + __d, | ||||||
|                       _STD::move(__pred)); |                       _STD::move(__pred)); | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -223,26 +223,26 @@ public: | |||||||
|     typedef duration::rep                    rep; |     typedef duration::rep                    rep; | ||||||
|     typedef duration::period                 period; |     typedef duration::period                 period; | ||||||
|     typedef chrono::time_point<system_clock> time_point; |     typedef chrono::time_point<system_clock> time_point; | ||||||
|     static const bool is_monotonic =          false; |     static const bool is_steady =            false; | ||||||
|  |  | ||||||
|     static time_point now(); |     static time_point now(); | ||||||
|     static time_t     to_time_t  (const time_point& __t); |     static time_t     to_time_t  (const time_point& __t); | ||||||
|     static time_point from_time_t(time_t __t); |     static time_point from_time_t(time_t __t); | ||||||
| }; | }; | ||||||
|  |  | ||||||
| class monotonic_clock | class steady_clock | ||||||
| { | { | ||||||
| public: | public: | ||||||
|     typedef nanoseconds                                   duration; |     typedef nanoseconds                                   duration; | ||||||
|     typedef duration::rep                                 rep; |     typedef duration::rep                                 rep; | ||||||
|     typedef duration::period                              period; |     typedef duration::period                              period; | ||||||
|     typedef chrono::time_point<monotonic_clock, duration> time_point; |     typedef chrono::time_point<steady_clock, duration>    time_point; | ||||||
|     static const bool is_monotonic =                       true; |     static const bool is_steady =                         true; | ||||||
|  |  | ||||||
|     static time_point now(); |     static time_point now(); | ||||||
| }; | }; | ||||||
|  |  | ||||||
| typedef monotonic_clock high_resolution_clock; | typedef steady_clock high_resolution_clock; | ||||||
|  |  | ||||||
| }  // chrono | }  // chrono | ||||||
|  |  | ||||||
| @@ -843,26 +843,26 @@ public: | |||||||
|     typedef duration::rep                    rep; |     typedef duration::rep                    rep; | ||||||
|     typedef duration::period                 period; |     typedef duration::period                 period; | ||||||
|     typedef chrono::time_point<system_clock> time_point; |     typedef chrono::time_point<system_clock> time_point; | ||||||
|     static const bool is_monotonic =          false; |     static const bool is_steady =            false; | ||||||
|  |  | ||||||
|     static time_point now(); |     static time_point now(); | ||||||
|     static time_t     to_time_t  (const time_point& __t); |     static time_t     to_time_t  (const time_point& __t); | ||||||
|     static time_point from_time_t(time_t __t); |     static time_point from_time_t(time_t __t); | ||||||
| }; | }; | ||||||
|  |  | ||||||
| class _LIBCPP_VISIBLE monotonic_clock | class _LIBCPP_VISIBLE steady_clock | ||||||
| { | { | ||||||
| public: | public: | ||||||
|     typedef nanoseconds                                   duration; |     typedef nanoseconds                                   duration; | ||||||
|     typedef duration::rep                                 rep; |     typedef duration::rep                                 rep; | ||||||
|     typedef duration::period                              period; |     typedef duration::period                              period; | ||||||
|     typedef chrono::time_point<monotonic_clock, duration> time_point; |     typedef chrono::time_point<steady_clock, duration>    time_point; | ||||||
|     static const bool is_monotonic =                       true; |     static const bool is_steady =                         true; | ||||||
|  |  | ||||||
|     static time_point now(); |     static time_point now(); | ||||||
| }; | }; | ||||||
|  |  | ||||||
| typedef monotonic_clock high_resolution_clock; | typedef steady_clock high_resolution_clock; | ||||||
|  |  | ||||||
| } // chrono | } // chrono | ||||||
|  |  | ||||||
|   | |||||||
| @@ -232,7 +232,7 @@ cv_status | |||||||
| condition_variable_any::wait_for(_Lock& __lock, | condition_variable_any::wait_for(_Lock& __lock, | ||||||
|                                  const chrono::duration<_Rep, _Period>& __d) |                                  const chrono::duration<_Rep, _Period>& __d) | ||||||
| { | { | ||||||
|     return wait_until(__lock, chrono::monotonic_clock::now() + __d); |     return wait_until(__lock, chrono::steady_clock::now() + __d); | ||||||
| } | } | ||||||
|  |  | ||||||
| template <class _Lock, class _Rep, class _Period, class _Predicate> | template <class _Lock, class _Rep, class _Period, class _Predicate> | ||||||
| @@ -242,7 +242,7 @@ condition_variable_any::wait_for(_Lock& __lock, | |||||||
|                                  const chrono::duration<_Rep, _Period>& __d, |                                  const chrono::duration<_Rep, _Period>& __d, | ||||||
|                                  _Predicate __pred) |                                  _Predicate __pred) | ||||||
| { | { | ||||||
|     return wait_until(__lock, chrono::monotonic_clock::now() + __d, |     return wait_until(__lock, chrono::steady_clock::now() + __d, | ||||||
|                       _STD::move(__pred)); |                       _STD::move(__pred)); | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -603,7 +603,7 @@ inline _LIBCPP_INLINE_VISIBILITY | |||||||
| future_status | future_status | ||||||
| __assoc_sub_state::wait_for(const chrono::duration<_Rep, _Period>& __rel_time) const | __assoc_sub_state::wait_for(const chrono::duration<_Rep, _Period>& __rel_time) const | ||||||
| { | { | ||||||
|     return wait_until(chrono::monotonic_clock::now() + __rel_time); |     return wait_until(chrono::steady_clock::now() + __rel_time); | ||||||
| } | } | ||||||
|  |  | ||||||
| template <class _R> | template <class _R> | ||||||
|   | |||||||
| @@ -221,7 +221,7 @@ public: | |||||||
|     template <class _Rep, class _Period> |     template <class _Rep, class _Period> | ||||||
|         _LIBCPP_INLINE_VISIBILITY |         _LIBCPP_INLINE_VISIBILITY | ||||||
|         bool try_lock_for(const chrono::duration<_Rep, _Period>& __d) |         bool try_lock_for(const chrono::duration<_Rep, _Period>& __d) | ||||||
|             {return try_lock_until(chrono::monotonic_clock::now() + __d);} |             {return try_lock_until(chrono::steady_clock::now() + __d);} | ||||||
|     template <class _Clock, class _Duration> |     template <class _Clock, class _Duration> | ||||||
|         bool try_lock_until(const chrono::time_point<_Clock, _Duration>& __t); |         bool try_lock_until(const chrono::time_point<_Clock, _Duration>& __t); | ||||||
|     void unlock(); |     void unlock(); | ||||||
| @@ -264,7 +264,7 @@ public: | |||||||
|     template <class _Rep, class _Period> |     template <class _Rep, class _Period> | ||||||
|         _LIBCPP_INLINE_VISIBILITY |         _LIBCPP_INLINE_VISIBILITY | ||||||
|         bool try_lock_for(const chrono::duration<_Rep, _Period>& __d) |         bool try_lock_for(const chrono::duration<_Rep, _Period>& __d) | ||||||
|             {return try_lock_until(chrono::monotonic_clock::now() + __d);} |             {return try_lock_until(chrono::steady_clock::now() + __d);} | ||||||
|     template <class _Clock, class _Duration> |     template <class _Clock, class _Duration> | ||||||
|         bool try_lock_until(const chrono::time_point<_Clock, _Duration>& __t); |         bool try_lock_until(const chrono::time_point<_Clock, _Duration>& __t); | ||||||
|     void unlock(); |     void unlock(); | ||||||
|   | |||||||
| @@ -406,10 +406,10 @@ sleep_until(const chrono::time_point<_Clock, _Duration>& __t) | |||||||
| template <class _Duration> | template <class _Duration> | ||||||
| inline _LIBCPP_INLINE_VISIBILITY | inline _LIBCPP_INLINE_VISIBILITY | ||||||
| void | void | ||||||
| sleep_until(const chrono::time_point<chrono::monotonic_clock, _Duration>& __t) | sleep_until(const chrono::time_point<chrono::steady_clock, _Duration>& __t) | ||||||
| { | { | ||||||
|     using namespace chrono; |     using namespace chrono; | ||||||
|     sleep_for(__t - monotonic_clock::now()); |     sleep_for(__t - steady_clock::now()); | ||||||
| } | } | ||||||
|  |  | ||||||
| inline _LIBCPP_INLINE_VISIBILITY | inline _LIBCPP_INLINE_VISIBILITY | ||||||
|   | |||||||
| @@ -44,7 +44,7 @@ system_clock::from_time_t(time_t t) | |||||||
|     return system_clock::time_point(seconds(t)); |     return system_clock::time_point(seconds(t)); | ||||||
| } | } | ||||||
|  |  | ||||||
| // monotonic_clock | // steady_clock | ||||||
|  |  | ||||||
| #if __APPLE__ | #if __APPLE__ | ||||||
| //   mach_absolute_time() * MachInfo.numer / MachInfo.denom is the number of | //   mach_absolute_time() * MachInfo.numer / MachInfo.denom is the number of | ||||||
| @@ -58,15 +58,15 @@ system_clock::from_time_t(time_t t) | |||||||
| #pragma GCC visibility push(hidden) | #pragma GCC visibility push(hidden) | ||||||
|  |  | ||||||
| static | static | ||||||
| monotonic_clock::rep | steady_clock::rep | ||||||
| monotonic_simplified() | steady_simplified() | ||||||
| { | { | ||||||
|     return mach_absolute_time(); |     return mach_absolute_time(); | ||||||
| } | } | ||||||
|  |  | ||||||
| static | static | ||||||
| double | double | ||||||
| compute_monotonic_factor() | compute_steady_factor() | ||||||
| { | { | ||||||
|     mach_timebase_info_data_t MachInfo; |     mach_timebase_info_data_t MachInfo; | ||||||
|     mach_timebase_info(&MachInfo); |     mach_timebase_info(&MachInfo); | ||||||
| @@ -74,32 +74,32 @@ compute_monotonic_factor() | |||||||
| } | } | ||||||
|  |  | ||||||
| static | static | ||||||
| monotonic_clock::rep | steady_clock::rep | ||||||
| monotonic_full() | steady_full() | ||||||
| { | { | ||||||
|     static const double factor = compute_monotonic_factor(); |     static const double factor = compute_steady_factor(); | ||||||
|     return static_cast<monotonic_clock::rep>(mach_absolute_time() * factor); |     return static_cast<steady_clock::rep>(mach_absolute_time() * factor); | ||||||
| } | } | ||||||
|  |  | ||||||
| typedef monotonic_clock::rep (*FP)(); | typedef steady_clock::rep (*FP)(); | ||||||
|  |  | ||||||
| static | static | ||||||
| FP | FP | ||||||
| init_monotonic_clock() | init_steady_clock() | ||||||
| { | { | ||||||
|     mach_timebase_info_data_t MachInfo; |     mach_timebase_info_data_t MachInfo; | ||||||
|     mach_timebase_info(&MachInfo); |     mach_timebase_info(&MachInfo); | ||||||
|     if (MachInfo.numer == MachInfo.denom) |     if (MachInfo.numer == MachInfo.denom) | ||||||
|         return &monotonic_simplified; |         return &steady_simplified; | ||||||
|     return &monotonic_full; |     return &steady_full; | ||||||
| } | } | ||||||
|  |  | ||||||
| #pragma GCC visibility pop | #pragma GCC visibility pop | ||||||
|  |  | ||||||
| monotonic_clock::time_point | steady_clock::time_point | ||||||
| monotonic_clock::now() | steady_clock::now() | ||||||
| { | { | ||||||
|     static FP fp = init_monotonic_clock(); |     static FP fp = init_steady_clock(); | ||||||
|     return time_point(duration(fp())); |     return time_point(duration(fp())); | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -109,12 +109,12 @@ monotonic_clock::now() | |||||||
| // _POSIX_MONOTONIC_CLOCK and fall back to something else if those | // _POSIX_MONOTONIC_CLOCK and fall back to something else if those | ||||||
| // don't exist. | // don't exist. | ||||||
|  |  | ||||||
| // Warning:  If this is not truly monotonic, then it is non-conforming.  It is | // Warning:  If this is not truly steady, then it is non-conforming.  It is | ||||||
| //  better for it to not exist and have the rest of libc++ use system_clock | //  better for it to not exist and have the rest of libc++ use system_clock | ||||||
| //  instead. | //  instead. | ||||||
|  |  | ||||||
| monotonic_clock::time_point | steady_clock::time_point | ||||||
| monotonic_clock::now() | steady_clock::now() | ||||||
| { | { | ||||||
|     struct timespec tp; |     struct timespec tp; | ||||||
|     if (0 != clock_gettime(CLOCK_MONOTONIC, &tp)) |     if (0 != clock_gettime(CLOCK_MONOTONIC, &tp)) | ||||||
|   | |||||||
| @@ -28,13 +28,13 @@ struct Clock | |||||||
|     typedef duration::rep             rep; |     typedef duration::rep             rep; | ||||||
|     typedef duration::period          period; |     typedef duration::period          period; | ||||||
|     typedef std::chrono::time_point<Clock> time_point; |     typedef std::chrono::time_point<Clock> time_point; | ||||||
|     static const bool is_monotonic =  true; |     static const bool is_steady =  true; | ||||||
|  |  | ||||||
|     static time_point now() |     static time_point now() | ||||||
|     { |     { | ||||||
|         using namespace std::chrono; |         using namespace std::chrono; | ||||||
|         return time_point(duration_cast<duration>( |         return time_point(duration_cast<duration>( | ||||||
|                 monotonic_clock::now().time_since_epoch() |                 steady_clock::now().time_since_epoch() | ||||||
|                                                  )); |                                                  )); | ||||||
|     } |     } | ||||||
| }; | }; | ||||||
|   | |||||||
| @@ -29,13 +29,13 @@ struct Clock | |||||||
|     typedef duration::rep             rep; |     typedef duration::rep             rep; | ||||||
|     typedef duration::period          period; |     typedef duration::period          period; | ||||||
|     typedef std::chrono::time_point<Clock> time_point; |     typedef std::chrono::time_point<Clock> time_point; | ||||||
|     static const bool is_monotonic =  true; |     static const bool is_steady =  true; | ||||||
|  |  | ||||||
|     static time_point now() |     static time_point now() | ||||||
|     { |     { | ||||||
|         using namespace std::chrono; |         using namespace std::chrono; | ||||||
|         return time_point(duration_cast<duration>( |         return time_point(duration_cast<duration>( | ||||||
|                 monotonic_clock::now().time_since_epoch() |                 steady_clock::now().time_since_epoch() | ||||||
|                                                  )); |                                                  )); | ||||||
|     } |     } | ||||||
| }; | }; | ||||||
|   | |||||||
| @@ -27,13 +27,13 @@ struct Clock | |||||||
|     typedef duration::rep             rep; |     typedef duration::rep             rep; | ||||||
|     typedef duration::period          period; |     typedef duration::period          period; | ||||||
|     typedef std::chrono::time_point<Clock> time_point; |     typedef std::chrono::time_point<Clock> time_point; | ||||||
|     static const bool is_monotonic =  true; |     static const bool is_steady =  true; | ||||||
|  |  | ||||||
|     static time_point now() |     static time_point now() | ||||||
|     { |     { | ||||||
|         using namespace std::chrono; |         using namespace std::chrono; | ||||||
|         return time_point(duration_cast<duration>( |         return time_point(duration_cast<duration>( | ||||||
|                 monotonic_clock::now().time_since_epoch() |                 steady_clock::now().time_since_epoch() | ||||||
|                                                  )); |                                                  )); | ||||||
|     } |     } | ||||||
| }; | }; | ||||||
|   | |||||||
| @@ -29,13 +29,13 @@ struct Clock | |||||||
|     typedef duration::rep             rep; |     typedef duration::rep             rep; | ||||||
|     typedef duration::period          period; |     typedef duration::period          period; | ||||||
|     typedef std::chrono::time_point<Clock> time_point; |     typedef std::chrono::time_point<Clock> time_point; | ||||||
|     static const bool is_monotonic =  true; |     static const bool is_steady =  true; | ||||||
|  |  | ||||||
|     static time_point now() |     static time_point now() | ||||||
|     { |     { | ||||||
|         using namespace std::chrono; |         using namespace std::chrono; | ||||||
|         return time_point(duration_cast<duration>( |         return time_point(duration_cast<duration>( | ||||||
|                 monotonic_clock::now().time_since_epoch() |                 steady_clock::now().time_since_epoch() | ||||||
|                                                  )); |                                                  )); | ||||||
|     } |     } | ||||||
| }; | }; | ||||||
|   | |||||||
| @@ -21,7 +21,7 @@ | |||||||
|  |  | ||||||
| std::timed_mutex m; | std::timed_mutex m; | ||||||
|  |  | ||||||
| typedef std::chrono::monotonic_clock Clock; | typedef std::chrono::steady_clock Clock; | ||||||
| typedef Clock::time_point time_point; | typedef Clock::time_point time_point; | ||||||
| typedef Clock::duration duration; | typedef Clock::duration duration; | ||||||
| typedef std::chrono::milliseconds ms; | typedef std::chrono::milliseconds ms; | ||||||
|   | |||||||
| @@ -21,7 +21,7 @@ | |||||||
|  |  | ||||||
| std::timed_mutex m; | std::timed_mutex m; | ||||||
|  |  | ||||||
| typedef std::chrono::monotonic_clock Clock; | typedef std::chrono::steady_clock Clock; | ||||||
| typedef Clock::time_point time_point; | typedef Clock::time_point time_point; | ||||||
| typedef Clock::duration duration; | typedef Clock::duration duration; | ||||||
| typedef std::chrono::milliseconds ms; | typedef std::chrono::milliseconds ms; | ||||||
|   | |||||||
| @@ -36,7 +36,7 @@ mutex m; | |||||||
|  |  | ||||||
| int main() | int main() | ||||||
| { | { | ||||||
|     typedef std::chrono::monotonic_clock Clock; |     typedef std::chrono::steady_clock Clock; | ||||||
|     std::unique_lock<mutex> lk(m, std::defer_lock); |     std::unique_lock<mutex> lk(m, std::defer_lock); | ||||||
|     assert(lk.try_lock_until(Clock::now()) == true); |     assert(lk.try_lock_until(Clock::now()) == true); | ||||||
|     assert(try_lock_until_called == true); |     assert(try_lock_until_called == true); | ||||||
|   | |||||||
| @@ -21,7 +21,7 @@ | |||||||
|  |  | ||||||
| std::timed_mutex m; | std::timed_mutex m; | ||||||
|  |  | ||||||
| typedef std::chrono::monotonic_clock Clock; | typedef std::chrono::steady_clock Clock; | ||||||
| typedef Clock::time_point time_point; | typedef Clock::time_point time_point; | ||||||
| typedef Clock::duration duration; | typedef Clock::duration duration; | ||||||
| typedef std::chrono::milliseconds ms; | typedef std::chrono::milliseconds ms; | ||||||
|   | |||||||
| @@ -21,7 +21,7 @@ | |||||||
|  |  | ||||||
| std::timed_mutex m; | std::timed_mutex m; | ||||||
|  |  | ||||||
| typedef std::chrono::monotonic_clock Clock; | typedef std::chrono::steady_clock Clock; | ||||||
| typedef Clock::time_point time_point; | typedef Clock::time_point time_point; | ||||||
| typedef Clock::duration duration; | typedef Clock::duration duration; | ||||||
| typedef std::chrono::milliseconds ms; | typedef std::chrono::milliseconds ms; | ||||||
|   | |||||||
| @@ -21,7 +21,7 @@ | |||||||
|  |  | ||||||
| std::recursive_timed_mutex m; | std::recursive_timed_mutex m; | ||||||
|  |  | ||||||
| typedef std::chrono::monotonic_clock Clock; | typedef std::chrono::steady_clock Clock; | ||||||
| typedef Clock::time_point time_point; | typedef Clock::time_point time_point; | ||||||
| typedef Clock::duration duration; | typedef Clock::duration duration; | ||||||
| typedef std::chrono::milliseconds ms; | typedef std::chrono::milliseconds ms; | ||||||
|   | |||||||
| @@ -21,7 +21,7 @@ | |||||||
|  |  | ||||||
| std::recursive_timed_mutex m; | std::recursive_timed_mutex m; | ||||||
|  |  | ||||||
| typedef std::chrono::monotonic_clock Clock; | typedef std::chrono::steady_clock Clock; | ||||||
| typedef Clock::time_point time_point; | typedef Clock::time_point time_point; | ||||||
| typedef Clock::duration duration; | typedef Clock::duration duration; | ||||||
| typedef std::chrono::milliseconds ms; | typedef std::chrono::milliseconds ms; | ||||||
|   | |||||||
| @@ -9,7 +9,7 @@ class Clock | |||||||
|     typedef duration::rep                            rep; |     typedef duration::rep                            rep; | ||||||
|     typedef duration::period                         period; |     typedef duration::period                         period; | ||||||
|     typedef std::chrono::time_point<Clock, duration> time_point; |     typedef std::chrono::time_point<Clock, duration> time_point; | ||||||
|     static const bool is_monotonic =                 false; |     static const bool is_steady =                    false; | ||||||
|  |  | ||||||
|     static time_point now(); |     static time_point now(); | ||||||
| }; | }; | ||||||
|   | |||||||
| @@ -21,5 +21,5 @@ int main() | |||||||
|     static_assert((std::is_same<C::rep, C::duration::rep>::value), ""); |     static_assert((std::is_same<C::rep, C::duration::rep>::value), ""); | ||||||
|     static_assert((std::is_same<C::period, C::duration::period>::value), ""); |     static_assert((std::is_same<C::period, C::duration::period>::value), ""); | ||||||
|     static_assert((std::is_same<C::duration, C::time_point::duration>::value), ""); |     static_assert((std::is_same<C::duration, C::time_point::duration>::value), ""); | ||||||
|     static_assert(C::is_monotonic || !C::is_monotonic, ""); |     static_assert(C::is_steady || !C::is_steady, ""); | ||||||
| } | } | ||||||
|   | |||||||
| @@ -9,7 +9,7 @@ | |||||||
|  |  | ||||||
| // <chrono> | // <chrono> | ||||||
|  |  | ||||||
| // monotonic_clock | // steady_clock | ||||||
|  |  | ||||||
| // check clock invariants | // check clock invariants | ||||||
|  |  | ||||||
| @@ -17,9 +17,9 @@ | |||||||
|  |  | ||||||
| int main() | int main() | ||||||
| { | { | ||||||
|     typedef std::chrono::monotonic_clock C; |     typedef std::chrono::steady_clock C; | ||||||
|     static_assert((std::is_same<C::rep, C::duration::rep>::value), ""); |     static_assert((std::is_same<C::rep, C::duration::rep>::value), ""); | ||||||
|     static_assert((std::is_same<C::period, C::duration::period>::value), ""); |     static_assert((std::is_same<C::period, C::duration::period>::value), ""); | ||||||
|     static_assert((std::is_same<C::duration, C::time_point::duration>::value), ""); |     static_assert((std::is_same<C::duration, C::time_point::duration>::value), ""); | ||||||
|     static_assert(C::is_monotonic, ""); |     static_assert(C::is_steady, ""); | ||||||
| } | } | ||||||
|   | |||||||
| @@ -9,7 +9,7 @@ | |||||||
|  |  | ||||||
| // <chrono> | // <chrono> | ||||||
|  |  | ||||||
| // monotonic_clock | // steady_clock | ||||||
|  |  | ||||||
| // static time_point now(); | // static time_point now(); | ||||||
|  |  | ||||||
| @@ -18,7 +18,7 @@ | |||||||
|  |  | ||||||
| int main() | int main() | ||||||
| { | { | ||||||
|     typedef std::chrono::monotonic_clock C; |     typedef std::chrono::steady_clock C; | ||||||
|     C::time_point t1 = C::now(); |     C::time_point t1 = C::now(); | ||||||
|     C::time_point t2 = C::now(); |     C::time_point t2 = C::now(); | ||||||
|     assert(t2 >= t1); |     assert(t2 >= t1); | ||||||
|   | |||||||
| @@ -22,5 +22,5 @@ int main() | |||||||
|     static_assert((std::is_same<C::period, C::duration::period>::value), ""); |     static_assert((std::is_same<C::period, C::duration::period>::value), ""); | ||||||
|     static_assert((std::is_same<C::duration, C::time_point::duration>::value), ""); |     static_assert((std::is_same<C::duration, C::time_point::duration>::value), ""); | ||||||
|     static_assert((std::is_same<C::time_point::clock, C>::value), ""); |     static_assert((std::is_same<C::time_point::clock, C>::value), ""); | ||||||
|     static_assert((C::is_monotonic || !C::is_monotonic), ""); |     static_assert((C::is_steady || !C::is_steady), ""); | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Howard Hinnant
					Howard Hinnant