diff options
author | Andrey Khalyavin <halyavin@gmail.com> | 2022-02-10 16:46:30 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:30 +0300 |
commit | 4b839d0704ee9be1dabb0310a1f03af24963637b (patch) | |
tree | 1a2c5ffcf89eb53ecd79dbc9bc0a195c27404d0c /contrib/libs/cxxsupp/libcxx/include/chrono | |
parent | f773626848a7c7456803654292e716b83d69cc12 (diff) | |
download | ydb-4b839d0704ee9be1dabb0310a1f03af24963637b.tar.gz |
Restoring authorship annotation for Andrey Khalyavin <halyavin@gmail.com>. Commit 2 of 2.
Diffstat (limited to 'contrib/libs/cxxsupp/libcxx/include/chrono')
-rw-r--r-- | contrib/libs/cxxsupp/libcxx/include/chrono | 3510 |
1 files changed, 1755 insertions, 1755 deletions
diff --git a/contrib/libs/cxxsupp/libcxx/include/chrono b/contrib/libs/cxxsupp/libcxx/include/chrono index 92720f32a1..db186a4fba 100644 --- a/contrib/libs/cxxsupp/libcxx/include/chrono +++ b/contrib/libs/cxxsupp/libcxx/include/chrono @@ -1,808 +1,808 @@ -// -*- C++ -*- -//===---------------------------- chrono ----------------------------------===// -// +// -*- C++ -*- +//===---------------------------- chrono ----------------------------------===// +// // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP_CHRONO -#define _LIBCPP_CHRONO - -/* - chrono synopsis - -namespace std -{ -namespace chrono -{ - -template <class ToDuration, class Rep, class Period> -constexpr -ToDuration -duration_cast(const duration<Rep, Period>& fd); - -template <class Rep> struct treat_as_floating_point : is_floating_point<Rep> {}; - -template <class Rep> inline constexpr bool treat_as_floating_point_v - = treat_as_floating_point<Rep>::value; // C++17 - -template <class Rep> -struct duration_values -{ -public: +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_CHRONO +#define _LIBCPP_CHRONO + +/* + chrono synopsis + +namespace std +{ +namespace chrono +{ + +template <class ToDuration, class Rep, class Period> +constexpr +ToDuration +duration_cast(const duration<Rep, Period>& fd); + +template <class Rep> struct treat_as_floating_point : is_floating_point<Rep> {}; + +template <class Rep> inline constexpr bool treat_as_floating_point_v + = treat_as_floating_point<Rep>::value; // C++17 + +template <class Rep> +struct duration_values +{ +public: static constexpr Rep zero(); // noexcept in C++20 static constexpr Rep max(); // noexcept in C++20 static constexpr Rep min(); // noexcept in C++20 -}; - -// duration - -template <class Rep, class Period = ratio<1>> -class duration -{ - static_assert(!__is_duration<Rep>::value, "A duration representation can not be a duration"); - static_assert(__is_ratio<Period>::value, "Second template parameter of duration must be a std::ratio"); - static_assert(Period::num > 0, "duration period must be positive"); -public: - typedef Rep rep; - typedef typename _Period::type period; - - constexpr duration() = default; - template <class Rep2> - constexpr explicit duration(const Rep2& r, - typename enable_if - < - is_convertible<Rep2, rep>::value && - (treat_as_floating_point<rep>::value || - !treat_as_floating_point<rep>::value && !treat_as_floating_point<Rep2>::value) - >::type* = 0); - - // conversions - template <class Rep2, class Period2> - constexpr duration(const duration<Rep2, Period2>& d, - typename enable_if - < - treat_as_floating_point<rep>::value || - ratio_divide<Period2, period>::type::den == 1 - >::type* = 0); - - // observer - - constexpr rep count() const; - - // arithmetic - - constexpr common_type<duration>::type operator+() const; - constexpr common_type<duration>::type operator-() const; +}; + +// duration + +template <class Rep, class Period = ratio<1>> +class duration +{ + static_assert(!__is_duration<Rep>::value, "A duration representation can not be a duration"); + static_assert(__is_ratio<Period>::value, "Second template parameter of duration must be a std::ratio"); + static_assert(Period::num > 0, "duration period must be positive"); +public: + typedef Rep rep; + typedef typename _Period::type period; + + constexpr duration() = default; + template <class Rep2> + constexpr explicit duration(const Rep2& r, + typename enable_if + < + is_convertible<Rep2, rep>::value && + (treat_as_floating_point<rep>::value || + !treat_as_floating_point<rep>::value && !treat_as_floating_point<Rep2>::value) + >::type* = 0); + + // conversions + template <class Rep2, class Period2> + constexpr duration(const duration<Rep2, Period2>& d, + typename enable_if + < + treat_as_floating_point<rep>::value || + ratio_divide<Period2, period>::type::den == 1 + >::type* = 0); + + // observer + + constexpr rep count() const; + + // arithmetic + + constexpr common_type<duration>::type operator+() const; + constexpr common_type<duration>::type operator-() const; constexpr duration& operator++(); // constexpr in C++17 constexpr duration operator++(int); // constexpr in C++17 constexpr duration& operator--(); // constexpr in C++17 constexpr duration operator--(int); // constexpr in C++17 - + constexpr duration& operator+=(const duration& d); // constexpr in C++17 constexpr duration& operator-=(const duration& d); // constexpr in C++17 - + duration& operator*=(const rep& rhs); // constexpr in C++17 duration& operator/=(const rep& rhs); // constexpr in C++17 duration& operator%=(const rep& rhs); // constexpr in C++17 duration& operator%=(const duration& rhs); // constexpr in C++17 - - // special values - + + // special values + static constexpr duration zero(); // noexcept in C++20 static constexpr duration min(); // noexcept in C++20 static constexpr duration max(); // noexcept in C++20 -}; - -typedef duration<long long, nano> nanoseconds; -typedef duration<long long, micro> microseconds; -typedef duration<long long, milli> milliseconds; -typedef duration<long long > seconds; -typedef duration< long, ratio< 60> > minutes; -typedef duration< long, ratio<3600> > hours; - -template <class Clock, class Duration = typename Clock::duration> -class time_point -{ -public: - typedef Clock clock; - typedef Duration duration; - typedef typename duration::rep rep; - typedef typename duration::period period; -private: - duration d_; // exposition only - -public: - time_point(); // has value "epoch" // constexpr in C++14 - explicit time_point(const duration& d); // same as time_point() + d // constexpr in C++14 - - // conversions - template <class Duration2> - time_point(const time_point<clock, Duration2>& t); // constexpr in C++14 - - // observer - - duration time_since_epoch() const; // constexpr in C++14 - - // arithmetic - +}; + +typedef duration<long long, nano> nanoseconds; +typedef duration<long long, micro> microseconds; +typedef duration<long long, milli> milliseconds; +typedef duration<long long > seconds; +typedef duration< long, ratio< 60> > minutes; +typedef duration< long, ratio<3600> > hours; + +template <class Clock, class Duration = typename Clock::duration> +class time_point +{ +public: + typedef Clock clock; + typedef Duration duration; + typedef typename duration::rep rep; + typedef typename duration::period period; +private: + duration d_; // exposition only + +public: + time_point(); // has value "epoch" // constexpr in C++14 + explicit time_point(const duration& d); // same as time_point() + d // constexpr in C++14 + + // conversions + template <class Duration2> + time_point(const time_point<clock, Duration2>& t); // constexpr in C++14 + + // observer + + duration time_since_epoch() const; // constexpr in C++14 + + // arithmetic + time_point& operator+=(const duration& d); // constexpr in C++17 time_point& operator-=(const duration& d); // constexpr in C++17 - - // special values - + + // special values + static constexpr time_point min(); // noexcept in C++20 static constexpr time_point max(); // noexcept in C++20 -}; - -} // chrono - -// common_type traits -template <class Rep1, class Period1, class Rep2, class Period2> - struct common_type<chrono::duration<Rep1, Period1>, chrono::duration<Rep2, Period2>>; - -template <class Clock, class Duration1, class Duration2> - struct common_type<chrono::time_point<Clock, Duration1>, chrono::time_point<Clock, Duration2>>; - -namespace chrono { - - -template<class T> struct is_clock; // C++20 -template<class T> inline constexpr bool is_clock_v = is_clock<T>::value; // C++20 - - -// duration arithmetic -template <class Rep1, class Period1, class Rep2, class Period2> - constexpr - typename common_type<duration<Rep1, Period1>, duration<Rep2, Period2>>::type - operator+(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs); -template <class Rep1, class Period1, class Rep2, class Period2> - constexpr - typename common_type<duration<Rep1, Period1>, duration<Rep2, Period2>>::type - operator-(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs); -template <class Rep1, class Period, class Rep2> - constexpr - duration<typename common_type<Rep1, Rep2>::type, Period> - operator*(const duration<Rep1, Period>& d, const Rep2& s); -template <class Rep1, class Period, class Rep2> - constexpr - duration<typename common_type<Rep1, Rep2>::type, Period> - operator*(const Rep1& s, const duration<Rep2, Period>& d); -template <class Rep1, class Period, class Rep2> - constexpr - duration<typename common_type<Rep1, Rep2>::type, Period> - operator/(const duration<Rep1, Period>& d, const Rep2& s); -template <class Rep1, class Period1, class Rep2, class Period2> - constexpr - typename common_type<Rep1, Rep2>::type - operator/(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs); - -// duration comparisons -template <class Rep1, class Period1, class Rep2, class Period2> - constexpr - bool operator==(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs); -template <class Rep1, class Period1, class Rep2, class Period2> - constexpr - bool operator!=(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs); -template <class Rep1, class Period1, class Rep2, class Period2> - constexpr - bool operator< (const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs); -template <class Rep1, class Period1, class Rep2, class Period2> - constexpr - bool operator<=(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs); -template <class Rep1, class Period1, class Rep2, class Period2> - constexpr - bool operator> (const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs); -template <class Rep1, class Period1, class Rep2, class Period2> - constexpr - bool operator>=(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs); - -// duration_cast -template <class ToDuration, class Rep, class Period> - ToDuration duration_cast(const duration<Rep, Period>& d); - -template <class ToDuration, class Rep, class Period> - constexpr ToDuration floor(const duration<Rep, Period>& d); // C++17 -template <class ToDuration, class Rep, class Period> - constexpr ToDuration ceil(const duration<Rep, Period>& d); // C++17 -template <class ToDuration, class Rep, class Period> - constexpr ToDuration round(const duration<Rep, Period>& d); // C++17 - -// duration I/O is elsewhere - -// time_point arithmetic (all constexpr in C++14) -template <class Clock, class Duration1, class Rep2, class Period2> - time_point<Clock, typename common_type<Duration1, duration<Rep2, Period2>>::type> - operator+(const time_point<Clock, Duration1>& lhs, const duration<Rep2, Period2>& rhs); -template <class Rep1, class Period1, class Clock, class Duration2> - time_point<Clock, typename common_type<duration<Rep1, Period1>, Duration2>::type> - operator+(const duration<Rep1, Period1>& lhs, const time_point<Clock, Duration2>& rhs); -template <class Clock, class Duration1, class Rep2, class Period2> - time_point<Clock, typename common_type<Duration1, duration<Rep2, Period2>>::type> - operator-(const time_point<Clock, Duration1>& lhs, const duration<Rep2, Period2>& rhs); -template <class Clock, class Duration1, class Duration2> - typename common_type<Duration1, Duration2>::type - operator-(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs); - -// time_point comparisons (all constexpr in C++14) -template <class Clock, class Duration1, class Duration2> - bool operator==(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs); -template <class Clock, class Duration1, class Duration2> - bool operator!=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs); -template <class Clock, class Duration1, class Duration2> - bool operator< (const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs); -template <class Clock, class Duration1, class Duration2> - bool operator<=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs); -template <class Clock, class Duration1, class Duration2> - bool operator> (const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs); -template <class Clock, class Duration1, class Duration2> - bool operator>=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs); - -// time_point_cast (constexpr in C++14) - -template <class ToDuration, class Clock, class Duration> - time_point<Clock, ToDuration> time_point_cast(const time_point<Clock, Duration>& t); - -template <class ToDuration, class Clock, class Duration> - constexpr time_point<Clock, ToDuration> - floor(const time_point<Clock, Duration>& tp); // C++17 - -template <class ToDuration, class Clock, class Duration> - constexpr time_point<Clock, ToDuration> - ceil(const time_point<Clock, Duration>& tp); // C++17 - -template <class ToDuration, class Clock, class Duration> - constexpr time_point<Clock, ToDuration> - round(const time_point<Clock, Duration>& tp); // C++17 - -template <class Rep, class Period> - constexpr duration<Rep, Period> abs(duration<Rep, Period> d); // C++17 - -// Clocks - -class system_clock -{ -public: - typedef microseconds duration; - typedef duration::rep rep; - typedef duration::period period; - typedef chrono::time_point<system_clock> time_point; - static const bool is_steady = false; // constexpr in C++14 - - static time_point now() noexcept; - static time_t to_time_t (const time_point& __t) noexcept; - static time_point from_time_t(time_t __t) noexcept; -}; - -template <class Duration> - using sys_time = time_point<system_clock, Duration>; // C++20 -using sys_seconds = sys_time<seconds>; // C++20 -using sys_days = sys_time<days>; // C++20 - -class utc_clock; // C++20 - -template <class Duration> - using utc_time = time_point<utc_clock, Duration>; // C++20 -using utc_seconds = utc_time<seconds>; // C++20 - -class tai_clock; // C++20 - -template <class Duration> - using tai_time = time_point<tai_clock, Duration>; // C++20 -using tai_seconds = tai_time<seconds>; // C++20 - -class file_clock; // C++20 - -template<class Duration> - using file_time = time_point<file_clock, Duration>; // C++20 - -class steady_clock -{ -public: - typedef nanoseconds duration; - typedef duration::rep rep; - typedef duration::period period; - typedef chrono::time_point<steady_clock, duration> time_point; - static const bool is_steady = true; // constexpr in C++14 - - static time_point now() noexcept; -}; - -typedef steady_clock high_resolution_clock; - -// 25.7.8, local time // C++20 -struct local_t {}; -template<class Duration> - using local_time = time_point<local_t, Duration>; -using local_seconds = local_time<seconds>; -using local_days = local_time<days>; - -// 25.7.9, time_point conversions template<class DestClock, class SourceClock> // C++20 -struct clock_time_conversion; - -template<class DestClock, class SourceClock, class Duration> - auto clock_cast(const time_point<SourceClock, Duration>& t); - -// 25.8.2, class last_spec // C++20 -struct last_spec; - -// 25.8.3, class day // C++20 - -class day; -constexpr bool operator==(const day& x, const day& y) noexcept; -constexpr bool operator!=(const day& x, const day& y) noexcept; -constexpr bool operator< (const day& x, const day& y) noexcept; -constexpr bool operator> (const day& x, const day& y) noexcept; -constexpr bool operator<=(const day& x, const day& y) noexcept; -constexpr bool operator>=(const day& x, const day& y) noexcept; -constexpr day operator+(const day& x, const days& y) noexcept; -constexpr day operator+(const days& x, const day& y) noexcept; -constexpr day operator-(const day& x, const days& y) noexcept; -constexpr days operator-(const day& x, const day& y) noexcept; - -// 25.8.4, class month // C++20 -class month; -constexpr bool operator==(const month& x, const month& y) noexcept; -constexpr bool operator!=(const month& x, const month& y) noexcept; -constexpr bool operator< (const month& x, const month& y) noexcept; -constexpr bool operator> (const month& x, const month& y) noexcept; -constexpr bool operator<=(const month& x, const month& y) noexcept; -constexpr bool operator>=(const month& x, const month& y) noexcept; -constexpr month operator+(const month& x, const months& y) noexcept; -constexpr month operator+(const months& x, const month& y) noexcept; -constexpr month operator-(const month& x, const months& y) noexcept; -constexpr months operator-(const month& x, const month& y) noexcept; - -// 25.8.5, class year // C++20 -class year; -constexpr bool operator==(const year& x, const year& y) noexcept; -constexpr bool operator!=(const year& x, const year& y) noexcept; -constexpr bool operator< (const year& x, const year& y) noexcept; -constexpr bool operator> (const year& x, const year& y) noexcept; -constexpr bool operator<=(const year& x, const year& y) noexcept; -constexpr bool operator>=(const year& x, const year& y) noexcept; -constexpr year operator+(const year& x, const years& y) noexcept; -constexpr year operator+(const years& x, const year& y) noexcept; -constexpr year operator-(const year& x, const years& y) noexcept; -constexpr years operator-(const year& x, const year& y) noexcept; - -// 25.8.6, class weekday // C++20 -class weekday; - -constexpr bool operator==(const weekday& x, const weekday& y) noexcept; -constexpr bool operator!=(const weekday& x, const weekday& y) noexcept; -constexpr weekday operator+(const weekday& x, const days& y) noexcept; -constexpr weekday operator+(const days& x, const weekday& y) noexcept; -constexpr weekday operator-(const weekday& x, const days& y) noexcept; -constexpr days operator-(const weekday& x, const weekday& y) noexcept; - -// 25.8.7, class weekday_indexed // C++20 - -class weekday_indexed; -constexpr bool operator==(const weekday_indexed& x, const weekday_indexed& y) noexcept; -constexpr bool operator!=(const weekday_indexed& x, const weekday_indexed& y) noexcept; - -// 25.8.8, class weekday_last // C++20 -class weekday_last; - -constexpr bool operator==(const weekday_last& x, const weekday_last& y) noexcept; -constexpr bool operator!=(const weekday_last& x, const weekday_last& y) noexcept; - -// 25.8.9, class month_day // C++20 -class month_day; - -constexpr bool operator==(const month_day& x, const month_day& y) noexcept; -constexpr bool operator!=(const month_day& x, const month_day& y) noexcept; -constexpr bool operator< (const month_day& x, const month_day& y) noexcept; -constexpr bool operator> (const month_day& x, const month_day& y) noexcept; -constexpr bool operator<=(const month_day& x, const month_day& y) noexcept; -constexpr bool operator>=(const month_day& x, const month_day& y) noexcept; - - -// 25.8.10, class month_day_last // C++20 -class month_day_last; - -constexpr bool operator==(const month_day_last& x, const month_day_last& y) noexcept; -constexpr bool operator!=(const month_day_last& x, const month_day_last& y) noexcept; -constexpr bool operator< (const month_day_last& x, const month_day_last& y) noexcept; -constexpr bool operator> (const month_day_last& x, const month_day_last& y) noexcept; -constexpr bool operator<=(const month_day_last& x, const month_day_last& y) noexcept; -constexpr bool operator>=(const month_day_last& x, const month_day_last& y) noexcept; - -// 25.8.11, class month_weekday // C++20 -class month_weekday; - -constexpr bool operator==(const month_weekday& x, const month_weekday& y) noexcept; -constexpr bool operator!=(const month_weekday& x, const month_weekday& y) noexcept; - -// 25.8.12, class month_weekday_last // C++20 -class month_weekday_last; - -constexpr bool operator==(const month_weekday_last& x, const month_weekday_last& y) noexcept; -constexpr bool operator!=(const month_weekday_last& x, const month_weekday_last& y) noexcept; - - -// 25.8.13, class year_month // C++20 -class year_month; - -constexpr bool operator==(const year_month& x, const year_month& y) noexcept; -constexpr bool operator!=(const year_month& x, const year_month& y) noexcept; -constexpr bool operator< (const year_month& x, const year_month& y) noexcept; -constexpr bool operator> (const year_month& x, const year_month& y) noexcept; -constexpr bool operator<=(const year_month& x, const year_month& y) noexcept; -constexpr bool operator>=(const year_month& x, const year_month& y) noexcept; - -constexpr year_month operator+(const year_month& ym, const months& dm) noexcept; -constexpr year_month operator+(const months& dm, const year_month& ym) noexcept; -constexpr year_month operator-(const year_month& ym, const months& dm) noexcept; -constexpr months operator-(const year_month& x, const year_month& y) noexcept; -constexpr year_month operator+(const year_month& ym, const years& dy) noexcept; -constexpr year_month operator+(const years& dy, const year_month& ym) noexcept; -constexpr year_month operator-(const year_month& ym, const years& dy) noexcept; - -// 25.8.14, class year_month_day class // C++20 -year_month_day; - -constexpr bool operator==(const year_month_day& x, const year_month_day& y) noexcept; -constexpr bool operator!=(const year_month_day& x, const year_month_day& y) noexcept; -constexpr bool operator< (const year_month_day& x, const year_month_day& y) noexcept; -constexpr bool operator> (const year_month_day& x, const year_month_day& y) noexcept; -constexpr bool operator<=(const year_month_day& x, const year_month_day& y) noexcept; -constexpr bool operator>=(const year_month_day& x, const year_month_day& y) noexcept; - -constexpr year_month_day operator+(const year_month_day& ymd, const months& dm) noexcept; -constexpr year_month_day operator+(const months& dm, const year_month_day& ymd) noexcept; -constexpr year_month_day operator+(const year_month_day& ymd, const years& dy) noexcept; -constexpr year_month_day operator+(const years& dy, const year_month_day& ymd) noexcept; -constexpr year_month_day operator-(const year_month_day& ymd, const months& dm) noexcept; -constexpr year_month_day operator-(const year_month_day& ymd, const years& dy) noexcept; - - -// 25.8.15, class year_month_day_last // C++20 -class year_month_day_last; - -constexpr bool operator==(const year_month_day_last& x, - const year_month_day_last& y) noexcept; -constexpr bool operator!=(const year_month_day_last& x, - const year_month_day_last& y) noexcept; -constexpr bool operator< (const year_month_day_last& x, - const year_month_day_last& y) noexcept; -constexpr bool operator> (const year_month_day_last& x, - const year_month_day_last& y) noexcept; -constexpr bool operator<=(const year_month_day_last& x, - const year_month_day_last& y) noexcept; -constexpr bool operator>=(const year_month_day_last& x, - const year_month_day_last& y) noexcept; - -constexpr year_month_day_last - operator+(const year_month_day_last& ymdl, const months& dm) noexcept; -constexpr year_month_day_last - operator+(const months& dm, const year_month_day_last& ymdl) noexcept; -constexpr year_month_day_last - operator+(const year_month_day_last& ymdl, const years& dy) noexcept; -constexpr year_month_day_last - operator+(const years& dy, const year_month_day_last& ymdl) noexcept; -constexpr year_month_day_last - operator-(const year_month_day_last& ymdl, const months& dm) noexcept; -constexpr year_month_day_last - operator-(const year_month_day_last& ymdl, const years& dy) noexcept; - -// 25.8.16, class year_month_weekday // C++20 -class year_month_weekday; - -constexpr bool operator==(const year_month_weekday& x, - const year_month_weekday& y) noexcept; -constexpr bool operator!=(const year_month_weekday& x, - const year_month_weekday& y) noexcept; - -constexpr year_month_weekday - operator+(const year_month_weekday& ymwd, const months& dm) noexcept; -constexpr year_month_weekday - operator+(const months& dm, const year_month_weekday& ymwd) noexcept; -constexpr year_month_weekday - operator+(const year_month_weekday& ymwd, const years& dy) noexcept; -constexpr year_month_weekday - operator+(const years& dy, const year_month_weekday& ymwd) noexcept; -constexpr year_month_weekday - operator-(const year_month_weekday& ymwd, const months& dm) noexcept; -constexpr year_month_weekday - operator-(const year_month_weekday& ymwd, const years& dy) noexcept; - -// 25.8.17, class year_month_weekday_last // C++20 -class year_month_weekday_last; - -constexpr bool operator==(const year_month_weekday_last& x, - const year_month_weekday_last& y) noexcept; -constexpr bool operator!=(const year_month_weekday_last& x, - const year_month_weekday_last& y) noexcept; -constexpr year_month_weekday_last - operator+(const year_month_weekday_last& ymwdl, const months& dm) noexcept; -constexpr year_month_weekday_last - operator+(const months& dm, const year_month_weekday_last& ymwdl) noexcept; -constexpr year_month_weekday_last - operator+(const year_month_weekday_last& ymwdl, const years& dy) noexcept; -constexpr year_month_weekday_last - operator+(const years& dy, const year_month_weekday_last& ymwdl) noexcept; -constexpr year_month_weekday_last - operator-(const year_month_weekday_last& ymwdl, const months& dm) noexcept; -constexpr year_month_weekday_last - operator-(const year_month_weekday_last& ymwdl, const years& dy) noexcept; - -// 25.8.18, civil calendar conventional syntax operators // C++20 -constexpr year_month - operator/(const year& y, const month& m) noexcept; -constexpr year_month - operator/(const year& y, int m) noexcept; -constexpr month_day - operator/(const month& m, const day& d) noexcept; -constexpr month_day - operator/(const month& m, int d) noexcept; -constexpr month_day - operator/(int m, const day& d) noexcept; -constexpr month_day - operator/(const day& d, const month& m) noexcept; -constexpr month_day - operator/(const day& d, int m) noexcept; -constexpr month_day_last - operator/(const month& m, last_spec) noexcept; -constexpr month_day_last - operator/(int m, last_spec) noexcept; -constexpr month_day_last - operator/(last_spec, const month& m) noexcept; -constexpr month_day_last - operator/(last_spec, int m) noexcept; -constexpr month_weekday - operator/(const month& m, const weekday_indexed& wdi) noexcept; -constexpr month_weekday - operator/(int m, const weekday_indexed& wdi) noexcept; -constexpr month_weekday - operator/(const weekday_indexed& wdi, const month& m) noexcept; -constexpr month_weekday - operator/(const weekday_indexed& wdi, int m) noexcept; -constexpr month_weekday_last - operator/(const month& m, const weekday_last& wdl) noexcept; -constexpr month_weekday_last - operator/(int m, const weekday_last& wdl) noexcept; -constexpr month_weekday_last - operator/(const weekday_last& wdl, const month& m) noexcept; -constexpr month_weekday_last - operator/(const weekday_last& wdl, int m) noexcept; -constexpr year_month_day - operator/(const year_month& ym, const day& d) noexcept; -constexpr year_month_day - operator/(const year_month& ym, int d) noexcept; -constexpr year_month_day - operator/(const year& y, const month_day& md) noexcept; -constexpr year_month_day - operator/(int y, const month_day& md) noexcept; -constexpr year_month_day - operator/(const month_day& md, const year& y) noexcept; -constexpr year_month_day - operator/(const month_day& md, int y) noexcept; -constexpr year_month_day_last - operator/(const year_month& ym, last_spec) noexcept; -constexpr year_month_day_last - operator/(const year& y, const month_day_last& mdl) noexcept; -constexpr year_month_day_last - operator/(int y, const month_day_last& mdl) noexcept; -constexpr year_month_day_last - operator/(const month_day_last& mdl, const year& y) noexcept; -constexpr year_month_day_last - operator/(const month_day_last& mdl, int y) noexcept; -constexpr year_month_weekday - operator/(const year_month& ym, const weekday_indexed& wdi) noexcept; -constexpr year_month_weekday - operator/(const year& y, const month_weekday& mwd) noexcept; -constexpr year_month_weekday - operator/(int y, const month_weekday& mwd) noexcept; -constexpr year_month_weekday - operator/(const month_weekday& mwd, const year& y) noexcept; -constexpr year_month_weekday - operator/(const month_weekday& mwd, int y) noexcept; -constexpr year_month_weekday_last - operator/(const year_month& ym, const weekday_last& wdl) noexcept; -constexpr year_month_weekday_last - operator/(const year& y, const month_weekday_last& mwdl) noexcept; -constexpr year_month_weekday_last - operator/(int y, const month_weekday_last& mwdl) noexcept; -constexpr year_month_weekday_last - operator/(const month_weekday_last& mwdl, const year& y) noexcept; -constexpr year_month_weekday_last - operator/(const month_weekday_last& mwdl, int y) noexcept; - -// 26.9, class template hh_mm_ss -template <class Duration> -class hh_mm_ss -{ - bool is_neg; // exposition only - chrono::hours h; // exposition only - chrono::minutes m; // exposition only - chrono::seconds s; // exposition only - precision ss; // exposition only - -public: - static unsigned constexpr fractional_width = see below; - using precision = see below; - - constexpr hh_mm_ss() noexcept : hh_mm_ss{Duration::zero()} {} - constexpr explicit hh_mm_ss(Duration d) noexcept; - - constexpr bool is_negative() const noexcept; - constexpr chrono::hours hours() const noexcept; - constexpr chrono::minutes minutes() const noexcept; - constexpr chrono::seconds seconds() const noexcept; - constexpr precision subseconds() const noexcept; - - constexpr explicit operator precision() const noexcept; - constexpr precision to_duration() const noexcept; -}; - -template <class charT, class traits, class Duration> - basic_ostream<charT, traits>& - operator<<(basic_ostream<charT, traits>& os, hh_mm_ss<Duration> const& hms); - -// 26.10, 12/24 hour functions -constexpr bool is_am(hours const& h) noexcept; -constexpr bool is_pm(hours const& h) noexcept; -constexpr hours make12(const hours& h) noexcept; -constexpr hours make24(const hours& h, bool is_pm) noexcept; - - -// 25.10.2, time zone database // C++20 -struct tzdb; -class tzdb_list; - -// 25.10.2.3, time zone database access // C++20 -const tzdb& get_tzdb(); -tzdb_list& get_tzdb_list(); -const time_zone* locate_zone(string_view tz_name); -const time_zone* current_zone(); - -// 25.10.2.4, remote time zone database support // C++20 -const tzdb& reload_tzdb(); -string remote_version(); - -// 25.10.3, exception classes // C++20 -class nonexistent_local_time; -class ambiguous_local_time; - -// 25.10.4, information classes // C++20 -struct sys_info; -struct local_info; - -// 25.10.5, class time_zone // C++20 -enum class choose {earliest, latest}; -class time_zone; -bool operator==(const time_zone& x, const time_zone& y) noexcept; -bool operator!=(const time_zone& x, const time_zone& y) noexcept; -bool operator<(const time_zone& x, const time_zone& y) noexcept; -bool operator>(const time_zone& x, const time_zone& y) noexcept; -bool operator<=(const time_zone& x, const time_zone& y) noexcept; -bool operator>=(const time_zone& x, const time_zone& y) noexcept; - -// 25.10.6, class template zoned_traits // C++20 -template<class T> struct zoned_traits; - -// 25.10.7, class template zoned_time // C++20 -template<class Duration, class TimeZonePtr = const time_zone*> class zoned_time; -using zoned_seconds = zoned_time<seconds>; - -template<class Duration1, class Duration2, class TimeZonePtr> - bool operator==(const zoned_time<Duration1, TimeZonePtr>& x, - const zoned_time<Duration2, TimeZonePtr>& y); -template<class Duration1, class Duration2, class TimeZonePtr> - bool operator!=(const zoned_time<Duration1, TimeZonePtr>& x, - const zoned_time<Duration2, TimeZonePtr>& y); - -// 25.10.8, leap second support // C++20 -class leap; - -bool operator==(const leap& x, const leap& y); -bool operator!=(const leap& x, const leap& y); -bool operator< (const leap& x, const leap& y); -bool operator> (const leap& x, const leap& y); -bool operator<=(const leap& x, const leap& y); -bool operator>=(const leap& x, const leap& y); -template<class Duration> - bool operator==(const leap& x, const sys_time<Duration>& y); -template<class Duration> - bool operator==(const sys_time<Duration>& x, const leap& y); -template<class Duration> - bool operator!=(const leap& x, const sys_time<Duration>& y); -template<class Duration> - bool operator!=(const sys_time<Duration>& x, const leap& y); -template<class Duration> - bool operator< (const leap& x, const sys_time<Duration>& y); -template<class Duration> - bool operator< (const sys_time<Duration>& x, const leap& y); -template<class Duration> - bool operator> (const leap& x, const sys_time<Duration>& y); -template<class Duration> - bool operator> (const sys_time<Duration>& x, const leap& y); -template<class Duration> - bool operator<=(const leap& x, const sys_time<Duration>& y); -template<class Duration> - bool operator<=(const sys_time<Duration>& x, const leap& y); -template<class Duration> - bool operator>=(const leap& x, const sys_time<Duration>& y); -template<class Duration> - bool operator>=(const sys_time<Duration>& x, const leap& y); - -// 25.10.9, class link // C++20 -class link; -bool operator==(const link& x, const link& y); -bool operator!=(const link& x, const link& y); -bool operator< (const link& x, const link& y); -bool operator> (const link& x, const link& y); -bool operator<=(const link& x, const link& y); -bool operator>=(const link& x, const link& y); - -// 25.11, formatting // C++20 -template<class charT, class Streamable> - basic_string<charT> - format(const charT* fmt, const Streamable& s); - -template<class charT, class Streamable> - basic_string<charT> - format(const locale& loc, const charT* fmt, const Streamable& s); - -template<class charT, class traits, class Alloc, class Streamable> - basic_string<charT, traits, Alloc> - format(const basic_string<charT, traits, Alloc>& fmt, const Streamable& s); - -template<class charT, class traits, class Alloc, class Streamable> - basic_string<charT, traits, Alloc> - format(const locale& loc, const basic_string<charT, traits, Alloc>& fmt, - const Streamable& s); - -// 25.12, parsing // C++20 -template<class charT, class traits, class Alloc, class Parsable> -unspecified - parse(const basic_string<charT, traits, Alloc>& format, Parsable& tp); - -template<class charT, class traits, class Alloc, class Parsable> -unspecified - parse(const basic_string<charT, traits, Alloc>& format, Parsable& tp, - basic_string<charT, traits, Alloc>& abbrev); - -template<class charT, class traits, class Alloc, class Parsable> -unspecified - parse(const basic_string<charT, traits, Alloc>& format, Parsable& tp, - minutes& offset); - -template<class charT, class traits, class Alloc, class Parsable> -unspecified - parse(const basic_string<charT, traits, Alloc>& format, Parsable& tp, - basic_string<charT, traits, Alloc>& abbrev, minutes& offset); - +}; + +} // chrono + +// common_type traits +template <class Rep1, class Period1, class Rep2, class Period2> + struct common_type<chrono::duration<Rep1, Period1>, chrono::duration<Rep2, Period2>>; + +template <class Clock, class Duration1, class Duration2> + struct common_type<chrono::time_point<Clock, Duration1>, chrono::time_point<Clock, Duration2>>; + +namespace chrono { + + +template<class T> struct is_clock; // C++20 +template<class T> inline constexpr bool is_clock_v = is_clock<T>::value; // C++20 + + +// duration arithmetic +template <class Rep1, class Period1, class Rep2, class Period2> + constexpr + typename common_type<duration<Rep1, Period1>, duration<Rep2, Period2>>::type + operator+(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs); +template <class Rep1, class Period1, class Rep2, class Period2> + constexpr + typename common_type<duration<Rep1, Period1>, duration<Rep2, Period2>>::type + operator-(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs); +template <class Rep1, class Period, class Rep2> + constexpr + duration<typename common_type<Rep1, Rep2>::type, Period> + operator*(const duration<Rep1, Period>& d, const Rep2& s); +template <class Rep1, class Period, class Rep2> + constexpr + duration<typename common_type<Rep1, Rep2>::type, Period> + operator*(const Rep1& s, const duration<Rep2, Period>& d); +template <class Rep1, class Period, class Rep2> + constexpr + duration<typename common_type<Rep1, Rep2>::type, Period> + operator/(const duration<Rep1, Period>& d, const Rep2& s); +template <class Rep1, class Period1, class Rep2, class Period2> + constexpr + typename common_type<Rep1, Rep2>::type + operator/(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs); + +// duration comparisons +template <class Rep1, class Period1, class Rep2, class Period2> + constexpr + bool operator==(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs); +template <class Rep1, class Period1, class Rep2, class Period2> + constexpr + bool operator!=(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs); +template <class Rep1, class Period1, class Rep2, class Period2> + constexpr + bool operator< (const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs); +template <class Rep1, class Period1, class Rep2, class Period2> + constexpr + bool operator<=(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs); +template <class Rep1, class Period1, class Rep2, class Period2> + constexpr + bool operator> (const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs); +template <class Rep1, class Period1, class Rep2, class Period2> + constexpr + bool operator>=(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs); + +// duration_cast +template <class ToDuration, class Rep, class Period> + ToDuration duration_cast(const duration<Rep, Period>& d); + +template <class ToDuration, class Rep, class Period> + constexpr ToDuration floor(const duration<Rep, Period>& d); // C++17 +template <class ToDuration, class Rep, class Period> + constexpr ToDuration ceil(const duration<Rep, Period>& d); // C++17 +template <class ToDuration, class Rep, class Period> + constexpr ToDuration round(const duration<Rep, Period>& d); // C++17 + +// duration I/O is elsewhere + +// time_point arithmetic (all constexpr in C++14) +template <class Clock, class Duration1, class Rep2, class Period2> + time_point<Clock, typename common_type<Duration1, duration<Rep2, Period2>>::type> + operator+(const time_point<Clock, Duration1>& lhs, const duration<Rep2, Period2>& rhs); +template <class Rep1, class Period1, class Clock, class Duration2> + time_point<Clock, typename common_type<duration<Rep1, Period1>, Duration2>::type> + operator+(const duration<Rep1, Period1>& lhs, const time_point<Clock, Duration2>& rhs); +template <class Clock, class Duration1, class Rep2, class Period2> + time_point<Clock, typename common_type<Duration1, duration<Rep2, Period2>>::type> + operator-(const time_point<Clock, Duration1>& lhs, const duration<Rep2, Period2>& rhs); +template <class Clock, class Duration1, class Duration2> + typename common_type<Duration1, Duration2>::type + operator-(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs); + +// time_point comparisons (all constexpr in C++14) +template <class Clock, class Duration1, class Duration2> + bool operator==(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs); +template <class Clock, class Duration1, class Duration2> + bool operator!=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs); +template <class Clock, class Duration1, class Duration2> + bool operator< (const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs); +template <class Clock, class Duration1, class Duration2> + bool operator<=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs); +template <class Clock, class Duration1, class Duration2> + bool operator> (const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs); +template <class Clock, class Duration1, class Duration2> + bool operator>=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs); + +// time_point_cast (constexpr in C++14) + +template <class ToDuration, class Clock, class Duration> + time_point<Clock, ToDuration> time_point_cast(const time_point<Clock, Duration>& t); + +template <class ToDuration, class Clock, class Duration> + constexpr time_point<Clock, ToDuration> + floor(const time_point<Clock, Duration>& tp); // C++17 + +template <class ToDuration, class Clock, class Duration> + constexpr time_point<Clock, ToDuration> + ceil(const time_point<Clock, Duration>& tp); // C++17 + +template <class ToDuration, class Clock, class Duration> + constexpr time_point<Clock, ToDuration> + round(const time_point<Clock, Duration>& tp); // C++17 + +template <class Rep, class Period> + constexpr duration<Rep, Period> abs(duration<Rep, Period> d); // C++17 + +// Clocks + +class system_clock +{ +public: + typedef microseconds duration; + typedef duration::rep rep; + typedef duration::period period; + typedef chrono::time_point<system_clock> time_point; + static const bool is_steady = false; // constexpr in C++14 + + static time_point now() noexcept; + static time_t to_time_t (const time_point& __t) noexcept; + static time_point from_time_t(time_t __t) noexcept; +}; + +template <class Duration> + using sys_time = time_point<system_clock, Duration>; // C++20 +using sys_seconds = sys_time<seconds>; // C++20 +using sys_days = sys_time<days>; // C++20 + +class utc_clock; // C++20 + +template <class Duration> + using utc_time = time_point<utc_clock, Duration>; // C++20 +using utc_seconds = utc_time<seconds>; // C++20 + +class tai_clock; // C++20 + +template <class Duration> + using tai_time = time_point<tai_clock, Duration>; // C++20 +using tai_seconds = tai_time<seconds>; // C++20 + +class file_clock; // C++20 + +template<class Duration> + using file_time = time_point<file_clock, Duration>; // C++20 + +class steady_clock +{ +public: + typedef nanoseconds duration; + typedef duration::rep rep; + typedef duration::period period; + typedef chrono::time_point<steady_clock, duration> time_point; + static const bool is_steady = true; // constexpr in C++14 + + static time_point now() noexcept; +}; + +typedef steady_clock high_resolution_clock; + +// 25.7.8, local time // C++20 +struct local_t {}; +template<class Duration> + using local_time = time_point<local_t, Duration>; +using local_seconds = local_time<seconds>; +using local_days = local_time<days>; + +// 25.7.9, time_point conversions template<class DestClock, class SourceClock> // C++20 +struct clock_time_conversion; + +template<class DestClock, class SourceClock, class Duration> + auto clock_cast(const time_point<SourceClock, Duration>& t); + +// 25.8.2, class last_spec // C++20 +struct last_spec; + +// 25.8.3, class day // C++20 + +class day; +constexpr bool operator==(const day& x, const day& y) noexcept; +constexpr bool operator!=(const day& x, const day& y) noexcept; +constexpr bool operator< (const day& x, const day& y) noexcept; +constexpr bool operator> (const day& x, const day& y) noexcept; +constexpr bool operator<=(const day& x, const day& y) noexcept; +constexpr bool operator>=(const day& x, const day& y) noexcept; +constexpr day operator+(const day& x, const days& y) noexcept; +constexpr day operator+(const days& x, const day& y) noexcept; +constexpr day operator-(const day& x, const days& y) noexcept; +constexpr days operator-(const day& x, const day& y) noexcept; + +// 25.8.4, class month // C++20 +class month; +constexpr bool operator==(const month& x, const month& y) noexcept; +constexpr bool operator!=(const month& x, const month& y) noexcept; +constexpr bool operator< (const month& x, const month& y) noexcept; +constexpr bool operator> (const month& x, const month& y) noexcept; +constexpr bool operator<=(const month& x, const month& y) noexcept; +constexpr bool operator>=(const month& x, const month& y) noexcept; +constexpr month operator+(const month& x, const months& y) noexcept; +constexpr month operator+(const months& x, const month& y) noexcept; +constexpr month operator-(const month& x, const months& y) noexcept; +constexpr months operator-(const month& x, const month& y) noexcept; + +// 25.8.5, class year // C++20 +class year; +constexpr bool operator==(const year& x, const year& y) noexcept; +constexpr bool operator!=(const year& x, const year& y) noexcept; +constexpr bool operator< (const year& x, const year& y) noexcept; +constexpr bool operator> (const year& x, const year& y) noexcept; +constexpr bool operator<=(const year& x, const year& y) noexcept; +constexpr bool operator>=(const year& x, const year& y) noexcept; +constexpr year operator+(const year& x, const years& y) noexcept; +constexpr year operator+(const years& x, const year& y) noexcept; +constexpr year operator-(const year& x, const years& y) noexcept; +constexpr years operator-(const year& x, const year& y) noexcept; + +// 25.8.6, class weekday // C++20 +class weekday; + +constexpr bool operator==(const weekday& x, const weekday& y) noexcept; +constexpr bool operator!=(const weekday& x, const weekday& y) noexcept; +constexpr weekday operator+(const weekday& x, const days& y) noexcept; +constexpr weekday operator+(const days& x, const weekday& y) noexcept; +constexpr weekday operator-(const weekday& x, const days& y) noexcept; +constexpr days operator-(const weekday& x, const weekday& y) noexcept; + +// 25.8.7, class weekday_indexed // C++20 + +class weekday_indexed; +constexpr bool operator==(const weekday_indexed& x, const weekday_indexed& y) noexcept; +constexpr bool operator!=(const weekday_indexed& x, const weekday_indexed& y) noexcept; + +// 25.8.8, class weekday_last // C++20 +class weekday_last; + +constexpr bool operator==(const weekday_last& x, const weekday_last& y) noexcept; +constexpr bool operator!=(const weekday_last& x, const weekday_last& y) noexcept; + +// 25.8.9, class month_day // C++20 +class month_day; + +constexpr bool operator==(const month_day& x, const month_day& y) noexcept; +constexpr bool operator!=(const month_day& x, const month_day& y) noexcept; +constexpr bool operator< (const month_day& x, const month_day& y) noexcept; +constexpr bool operator> (const month_day& x, const month_day& y) noexcept; +constexpr bool operator<=(const month_day& x, const month_day& y) noexcept; +constexpr bool operator>=(const month_day& x, const month_day& y) noexcept; + + +// 25.8.10, class month_day_last // C++20 +class month_day_last; + +constexpr bool operator==(const month_day_last& x, const month_day_last& y) noexcept; +constexpr bool operator!=(const month_day_last& x, const month_day_last& y) noexcept; +constexpr bool operator< (const month_day_last& x, const month_day_last& y) noexcept; +constexpr bool operator> (const month_day_last& x, const month_day_last& y) noexcept; +constexpr bool operator<=(const month_day_last& x, const month_day_last& y) noexcept; +constexpr bool operator>=(const month_day_last& x, const month_day_last& y) noexcept; + +// 25.8.11, class month_weekday // C++20 +class month_weekday; + +constexpr bool operator==(const month_weekday& x, const month_weekday& y) noexcept; +constexpr bool operator!=(const month_weekday& x, const month_weekday& y) noexcept; + +// 25.8.12, class month_weekday_last // C++20 +class month_weekday_last; + +constexpr bool operator==(const month_weekday_last& x, const month_weekday_last& y) noexcept; +constexpr bool operator!=(const month_weekday_last& x, const month_weekday_last& y) noexcept; + + +// 25.8.13, class year_month // C++20 +class year_month; + +constexpr bool operator==(const year_month& x, const year_month& y) noexcept; +constexpr bool operator!=(const year_month& x, const year_month& y) noexcept; +constexpr bool operator< (const year_month& x, const year_month& y) noexcept; +constexpr bool operator> (const year_month& x, const year_month& y) noexcept; +constexpr bool operator<=(const year_month& x, const year_month& y) noexcept; +constexpr bool operator>=(const year_month& x, const year_month& y) noexcept; + +constexpr year_month operator+(const year_month& ym, const months& dm) noexcept; +constexpr year_month operator+(const months& dm, const year_month& ym) noexcept; +constexpr year_month operator-(const year_month& ym, const months& dm) noexcept; +constexpr months operator-(const year_month& x, const year_month& y) noexcept; +constexpr year_month operator+(const year_month& ym, const years& dy) noexcept; +constexpr year_month operator+(const years& dy, const year_month& ym) noexcept; +constexpr year_month operator-(const year_month& ym, const years& dy) noexcept; + +// 25.8.14, class year_month_day class // C++20 +year_month_day; + +constexpr bool operator==(const year_month_day& x, const year_month_day& y) noexcept; +constexpr bool operator!=(const year_month_day& x, const year_month_day& y) noexcept; +constexpr bool operator< (const year_month_day& x, const year_month_day& y) noexcept; +constexpr bool operator> (const year_month_day& x, const year_month_day& y) noexcept; +constexpr bool operator<=(const year_month_day& x, const year_month_day& y) noexcept; +constexpr bool operator>=(const year_month_day& x, const year_month_day& y) noexcept; + +constexpr year_month_day operator+(const year_month_day& ymd, const months& dm) noexcept; +constexpr year_month_day operator+(const months& dm, const year_month_day& ymd) noexcept; +constexpr year_month_day operator+(const year_month_day& ymd, const years& dy) noexcept; +constexpr year_month_day operator+(const years& dy, const year_month_day& ymd) noexcept; +constexpr year_month_day operator-(const year_month_day& ymd, const months& dm) noexcept; +constexpr year_month_day operator-(const year_month_day& ymd, const years& dy) noexcept; + + +// 25.8.15, class year_month_day_last // C++20 +class year_month_day_last; + +constexpr bool operator==(const year_month_day_last& x, + const year_month_day_last& y) noexcept; +constexpr bool operator!=(const year_month_day_last& x, + const year_month_day_last& y) noexcept; +constexpr bool operator< (const year_month_day_last& x, + const year_month_day_last& y) noexcept; +constexpr bool operator> (const year_month_day_last& x, + const year_month_day_last& y) noexcept; +constexpr bool operator<=(const year_month_day_last& x, + const year_month_day_last& y) noexcept; +constexpr bool operator>=(const year_month_day_last& x, + const year_month_day_last& y) noexcept; + +constexpr year_month_day_last + operator+(const year_month_day_last& ymdl, const months& dm) noexcept; +constexpr year_month_day_last + operator+(const months& dm, const year_month_day_last& ymdl) noexcept; +constexpr year_month_day_last + operator+(const year_month_day_last& ymdl, const years& dy) noexcept; +constexpr year_month_day_last + operator+(const years& dy, const year_month_day_last& ymdl) noexcept; +constexpr year_month_day_last + operator-(const year_month_day_last& ymdl, const months& dm) noexcept; +constexpr year_month_day_last + operator-(const year_month_day_last& ymdl, const years& dy) noexcept; + +// 25.8.16, class year_month_weekday // C++20 +class year_month_weekday; + +constexpr bool operator==(const year_month_weekday& x, + const year_month_weekday& y) noexcept; +constexpr bool operator!=(const year_month_weekday& x, + const year_month_weekday& y) noexcept; + +constexpr year_month_weekday + operator+(const year_month_weekday& ymwd, const months& dm) noexcept; +constexpr year_month_weekday + operator+(const months& dm, const year_month_weekday& ymwd) noexcept; +constexpr year_month_weekday + operator+(const year_month_weekday& ymwd, const years& dy) noexcept; +constexpr year_month_weekday + operator+(const years& dy, const year_month_weekday& ymwd) noexcept; +constexpr year_month_weekday + operator-(const year_month_weekday& ymwd, const months& dm) noexcept; +constexpr year_month_weekday + operator-(const year_month_weekday& ymwd, const years& dy) noexcept; + +// 25.8.17, class year_month_weekday_last // C++20 +class year_month_weekday_last; + +constexpr bool operator==(const year_month_weekday_last& x, + const year_month_weekday_last& y) noexcept; +constexpr bool operator!=(const year_month_weekday_last& x, + const year_month_weekday_last& y) noexcept; +constexpr year_month_weekday_last + operator+(const year_month_weekday_last& ymwdl, const months& dm) noexcept; +constexpr year_month_weekday_last + operator+(const months& dm, const year_month_weekday_last& ymwdl) noexcept; +constexpr year_month_weekday_last + operator+(const year_month_weekday_last& ymwdl, const years& dy) noexcept; +constexpr year_month_weekday_last + operator+(const years& dy, const year_month_weekday_last& ymwdl) noexcept; +constexpr year_month_weekday_last + operator-(const year_month_weekday_last& ymwdl, const months& dm) noexcept; +constexpr year_month_weekday_last + operator-(const year_month_weekday_last& ymwdl, const years& dy) noexcept; + +// 25.8.18, civil calendar conventional syntax operators // C++20 +constexpr year_month + operator/(const year& y, const month& m) noexcept; +constexpr year_month + operator/(const year& y, int m) noexcept; +constexpr month_day + operator/(const month& m, const day& d) noexcept; +constexpr month_day + operator/(const month& m, int d) noexcept; +constexpr month_day + operator/(int m, const day& d) noexcept; +constexpr month_day + operator/(const day& d, const month& m) noexcept; +constexpr month_day + operator/(const day& d, int m) noexcept; +constexpr month_day_last + operator/(const month& m, last_spec) noexcept; +constexpr month_day_last + operator/(int m, last_spec) noexcept; +constexpr month_day_last + operator/(last_spec, const month& m) noexcept; +constexpr month_day_last + operator/(last_spec, int m) noexcept; +constexpr month_weekday + operator/(const month& m, const weekday_indexed& wdi) noexcept; +constexpr month_weekday + operator/(int m, const weekday_indexed& wdi) noexcept; +constexpr month_weekday + operator/(const weekday_indexed& wdi, const month& m) noexcept; +constexpr month_weekday + operator/(const weekday_indexed& wdi, int m) noexcept; +constexpr month_weekday_last + operator/(const month& m, const weekday_last& wdl) noexcept; +constexpr month_weekday_last + operator/(int m, const weekday_last& wdl) noexcept; +constexpr month_weekday_last + operator/(const weekday_last& wdl, const month& m) noexcept; +constexpr month_weekday_last + operator/(const weekday_last& wdl, int m) noexcept; +constexpr year_month_day + operator/(const year_month& ym, const day& d) noexcept; +constexpr year_month_day + operator/(const year_month& ym, int d) noexcept; +constexpr year_month_day + operator/(const year& y, const month_day& md) noexcept; +constexpr year_month_day + operator/(int y, const month_day& md) noexcept; +constexpr year_month_day + operator/(const month_day& md, const year& y) noexcept; +constexpr year_month_day + operator/(const month_day& md, int y) noexcept; +constexpr year_month_day_last + operator/(const year_month& ym, last_spec) noexcept; +constexpr year_month_day_last + operator/(const year& y, const month_day_last& mdl) noexcept; +constexpr year_month_day_last + operator/(int y, const month_day_last& mdl) noexcept; +constexpr year_month_day_last + operator/(const month_day_last& mdl, const year& y) noexcept; +constexpr year_month_day_last + operator/(const month_day_last& mdl, int y) noexcept; +constexpr year_month_weekday + operator/(const year_month& ym, const weekday_indexed& wdi) noexcept; +constexpr year_month_weekday + operator/(const year& y, const month_weekday& mwd) noexcept; +constexpr year_month_weekday + operator/(int y, const month_weekday& mwd) noexcept; +constexpr year_month_weekday + operator/(const month_weekday& mwd, const year& y) noexcept; +constexpr year_month_weekday + operator/(const month_weekday& mwd, int y) noexcept; +constexpr year_month_weekday_last + operator/(const year_month& ym, const weekday_last& wdl) noexcept; +constexpr year_month_weekday_last + operator/(const year& y, const month_weekday_last& mwdl) noexcept; +constexpr year_month_weekday_last + operator/(int y, const month_weekday_last& mwdl) noexcept; +constexpr year_month_weekday_last + operator/(const month_weekday_last& mwdl, const year& y) noexcept; +constexpr year_month_weekday_last + operator/(const month_weekday_last& mwdl, int y) noexcept; + +// 26.9, class template hh_mm_ss +template <class Duration> +class hh_mm_ss +{ + bool is_neg; // exposition only + chrono::hours h; // exposition only + chrono::minutes m; // exposition only + chrono::seconds s; // exposition only + precision ss; // exposition only + +public: + static unsigned constexpr fractional_width = see below; + using precision = see below; + + constexpr hh_mm_ss() noexcept : hh_mm_ss{Duration::zero()} {} + constexpr explicit hh_mm_ss(Duration d) noexcept; + + constexpr bool is_negative() const noexcept; + constexpr chrono::hours hours() const noexcept; + constexpr chrono::minutes minutes() const noexcept; + constexpr chrono::seconds seconds() const noexcept; + constexpr precision subseconds() const noexcept; + + constexpr explicit operator precision() const noexcept; + constexpr precision to_duration() const noexcept; +}; + +template <class charT, class traits, class Duration> + basic_ostream<charT, traits>& + operator<<(basic_ostream<charT, traits>& os, hh_mm_ss<Duration> const& hms); + +// 26.10, 12/24 hour functions +constexpr bool is_am(hours const& h) noexcept; +constexpr bool is_pm(hours const& h) noexcept; +constexpr hours make12(const hours& h) noexcept; +constexpr hours make24(const hours& h, bool is_pm) noexcept; + + +// 25.10.2, time zone database // C++20 +struct tzdb; +class tzdb_list; + +// 25.10.2.3, time zone database access // C++20 +const tzdb& get_tzdb(); +tzdb_list& get_tzdb_list(); +const time_zone* locate_zone(string_view tz_name); +const time_zone* current_zone(); + +// 25.10.2.4, remote time zone database support // C++20 +const tzdb& reload_tzdb(); +string remote_version(); + +// 25.10.3, exception classes // C++20 +class nonexistent_local_time; +class ambiguous_local_time; + +// 25.10.4, information classes // C++20 +struct sys_info; +struct local_info; + +// 25.10.5, class time_zone // C++20 +enum class choose {earliest, latest}; +class time_zone; +bool operator==(const time_zone& x, const time_zone& y) noexcept; +bool operator!=(const time_zone& x, const time_zone& y) noexcept; +bool operator<(const time_zone& x, const time_zone& y) noexcept; +bool operator>(const time_zone& x, const time_zone& y) noexcept; +bool operator<=(const time_zone& x, const time_zone& y) noexcept; +bool operator>=(const time_zone& x, const time_zone& y) noexcept; + +// 25.10.6, class template zoned_traits // C++20 +template<class T> struct zoned_traits; + +// 25.10.7, class template zoned_time // C++20 +template<class Duration, class TimeZonePtr = const time_zone*> class zoned_time; +using zoned_seconds = zoned_time<seconds>; + +template<class Duration1, class Duration2, class TimeZonePtr> + bool operator==(const zoned_time<Duration1, TimeZonePtr>& x, + const zoned_time<Duration2, TimeZonePtr>& y); +template<class Duration1, class Duration2, class TimeZonePtr> + bool operator!=(const zoned_time<Duration1, TimeZonePtr>& x, + const zoned_time<Duration2, TimeZonePtr>& y); + +// 25.10.8, leap second support // C++20 +class leap; + +bool operator==(const leap& x, const leap& y); +bool operator!=(const leap& x, const leap& y); +bool operator< (const leap& x, const leap& y); +bool operator> (const leap& x, const leap& y); +bool operator<=(const leap& x, const leap& y); +bool operator>=(const leap& x, const leap& y); +template<class Duration> + bool operator==(const leap& x, const sys_time<Duration>& y); +template<class Duration> + bool operator==(const sys_time<Duration>& x, const leap& y); +template<class Duration> + bool operator!=(const leap& x, const sys_time<Duration>& y); +template<class Duration> + bool operator!=(const sys_time<Duration>& x, const leap& y); +template<class Duration> + bool operator< (const leap& x, const sys_time<Duration>& y); +template<class Duration> + bool operator< (const sys_time<Duration>& x, const leap& y); +template<class Duration> + bool operator> (const leap& x, const sys_time<Duration>& y); +template<class Duration> + bool operator> (const sys_time<Duration>& x, const leap& y); +template<class Duration> + bool operator<=(const leap& x, const sys_time<Duration>& y); +template<class Duration> + bool operator<=(const sys_time<Duration>& x, const leap& y); +template<class Duration> + bool operator>=(const leap& x, const sys_time<Duration>& y); +template<class Duration> + bool operator>=(const sys_time<Duration>& x, const leap& y); + +// 25.10.9, class link // C++20 +class link; +bool operator==(const link& x, const link& y); +bool operator!=(const link& x, const link& y); +bool operator< (const link& x, const link& y); +bool operator> (const link& x, const link& y); +bool operator<=(const link& x, const link& y); +bool operator>=(const link& x, const link& y); + +// 25.11, formatting // C++20 +template<class charT, class Streamable> + basic_string<charT> + format(const charT* fmt, const Streamable& s); + +template<class charT, class Streamable> + basic_string<charT> + format(const locale& loc, const charT* fmt, const Streamable& s); + +template<class charT, class traits, class Alloc, class Streamable> + basic_string<charT, traits, Alloc> + format(const basic_string<charT, traits, Alloc>& fmt, const Streamable& s); + +template<class charT, class traits, class Alloc, class Streamable> + basic_string<charT, traits, Alloc> + format(const locale& loc, const basic_string<charT, traits, Alloc>& fmt, + const Streamable& s); + +// 25.12, parsing // C++20 +template<class charT, class traits, class Alloc, class Parsable> +unspecified + parse(const basic_string<charT, traits, Alloc>& format, Parsable& tp); + +template<class charT, class traits, class Alloc, class Parsable> +unspecified + parse(const basic_string<charT, traits, Alloc>& format, Parsable& tp, + basic_string<charT, traits, Alloc>& abbrev); + +template<class charT, class traits, class Alloc, class Parsable> +unspecified + parse(const basic_string<charT, traits, Alloc>& format, Parsable& tp, + minutes& offset); + +template<class charT, class traits, class Alloc, class Parsable> +unspecified + parse(const basic_string<charT, traits, Alloc>& format, Parsable& tp, + basic_string<charT, traits, Alloc>& abbrev, minutes& offset); + // calendrical constants inline constexpr last_spec last{}; // C++20 -inline constexpr chrono::weekday Sunday{0}; // C++20 -inline constexpr chrono::weekday Monday{1}; // C++20 -inline constexpr chrono::weekday Tuesday{2}; // C++20 -inline constexpr chrono::weekday Wednesday{3}; // C++20 -inline constexpr chrono::weekday Thursday{4}; // C++20 -inline constexpr chrono::weekday Friday{5}; // C++20 -inline constexpr chrono::weekday Saturday{6}; // C++20 - -inline constexpr chrono::month January{1}; // C++20 -inline constexpr chrono::month February{2}; // C++20 -inline constexpr chrono::month March{3}; // C++20 -inline constexpr chrono::month April{4}; // C++20 -inline constexpr chrono::month May{5}; // C++20 -inline constexpr chrono::month June{6}; // C++20 -inline constexpr chrono::month July{7}; // C++20 -inline constexpr chrono::month August{8}; // C++20 -inline constexpr chrono::month September{9}; // C++20 -inline constexpr chrono::month October{10}; // C++20 -inline constexpr chrono::month November{11}; // C++20 -inline constexpr chrono::month December{12}; // C++20 -} // chrono - -inline namespace literals { - inline namespace chrono_literals { +inline constexpr chrono::weekday Sunday{0}; // C++20 +inline constexpr chrono::weekday Monday{1}; // C++20 +inline constexpr chrono::weekday Tuesday{2}; // C++20 +inline constexpr chrono::weekday Wednesday{3}; // C++20 +inline constexpr chrono::weekday Thursday{4}; // C++20 +inline constexpr chrono::weekday Friday{5}; // C++20 +inline constexpr chrono::weekday Saturday{6}; // C++20 + +inline constexpr chrono::month January{1}; // C++20 +inline constexpr chrono::month February{2}; // C++20 +inline constexpr chrono::month March{3}; // C++20 +inline constexpr chrono::month April{4}; // C++20 +inline constexpr chrono::month May{5}; // C++20 +inline constexpr chrono::month June{6}; // C++20 +inline constexpr chrono::month July{7}; // C++20 +inline constexpr chrono::month August{8}; // C++20 +inline constexpr chrono::month September{9}; // C++20 +inline constexpr chrono::month October{10}; // C++20 +inline constexpr chrono::month November{11}; // C++20 +inline constexpr chrono::month December{12}; // C++20 +} // chrono + +inline namespace literals { + inline namespace chrono_literals { constexpr chrono::hours operator ""h(unsigned long long); // C++14 constexpr chrono::duration<unspecified , ratio<3600,1>> operator ""h(long double); // C++14 constexpr chrono::minutes operator ""min(unsigned long long); // C++14 @@ -815,797 +815,797 @@ constexpr chrono::microseconds operator ""us(unsigned l constexpr chrono::duration<unspecified , micro> operator ""us(long double); // C++14 constexpr chrono::nanoseconds operator ""ns(unsigned long long); // C++14 constexpr chrono::duration<unspecified , nano> operator ""ns(long double); // C++14 -constexpr chrono::day operator ""d(unsigned long long d) noexcept; // C++20 -constexpr chrono::year operator ""y(unsigned long long y) noexcept; // C++20 -} // chrono_literals -} // literals - -} // std -*/ - -#include <__availability> -#include <__config> -#include <compare> -#include <ctime> -#include <limits> -#include <ratio> -#include <type_traits> +constexpr chrono::day operator ""d(unsigned long long d) noexcept; // C++20 +constexpr chrono::year operator ""y(unsigned long long y) noexcept; // C++20 +} // chrono_literals +} // literals + +} // std +*/ + +#include <__availability> +#include <__config> +#include <compare> +#include <ctime> +#include <limits> +#include <ratio> +#include <type_traits> #include <version> - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_PUSH_MACROS -#include <__undef_macros> - -#ifdef _LIBCPP_COMPILER_MSVC -#pragma warning ( push ) -#pragma warning ( disable : 4455) -#endif - + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +#ifdef _LIBCPP_COMPILER_MSVC +#pragma warning ( push ) +#pragma warning ( disable : 4455) +#endif + #ifndef _LIBCPP_CXX03_LANG _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM struct _FilesystemClock; _LIBCPP_END_NAMESPACE_FILESYSTEM #endif // !_LIBCPP_CXX03_LANG -_LIBCPP_BEGIN_NAMESPACE_STD - -namespace chrono -{ - -template <class _Rep, class _Period = ratio<1> > class _LIBCPP_TEMPLATE_VIS duration; - -template <class _Tp> -struct __is_duration : false_type {}; - -template <class _Rep, class _Period> -struct __is_duration<duration<_Rep, _Period> > : true_type {}; - -template <class _Rep, class _Period> -struct __is_duration<const duration<_Rep, _Period> > : true_type {}; - -template <class _Rep, class _Period> -struct __is_duration<volatile duration<_Rep, _Period> > : true_type {}; - -template <class _Rep, class _Period> -struct __is_duration<const volatile duration<_Rep, _Period> > : true_type {}; - -} // chrono - -template <class _Rep1, class _Period1, class _Rep2, class _Period2> -struct _LIBCPP_TEMPLATE_VIS common_type<chrono::duration<_Rep1, _Period1>, - chrono::duration<_Rep2, _Period2> > -{ - typedef chrono::duration<typename common_type<_Rep1, _Rep2>::type, - typename __ratio_gcd<_Period1, _Period2>::type> type; -}; - -namespace chrono { - -// duration_cast - -template <class _FromDuration, class _ToDuration, - class _Period = typename ratio_divide<typename _FromDuration::period, typename _ToDuration::period>::type, - bool = _Period::num == 1, - bool = _Period::den == 1> -struct __duration_cast; - -template <class _FromDuration, class _ToDuration, class _Period> -struct __duration_cast<_FromDuration, _ToDuration, _Period, true, true> -{ - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR - _ToDuration operator()(const _FromDuration& __fd) const - { - return _ToDuration(static_cast<typename _ToDuration::rep>(__fd.count())); - } -}; - -template <class _FromDuration, class _ToDuration, class _Period> -struct __duration_cast<_FromDuration, _ToDuration, _Period, true, false> -{ - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR - _ToDuration operator()(const _FromDuration& __fd) const - { - typedef typename common_type<typename _ToDuration::rep, typename _FromDuration::rep, intmax_t>::type _Ct; - return _ToDuration(static_cast<typename _ToDuration::rep>( - static_cast<_Ct>(__fd.count()) / static_cast<_Ct>(_Period::den))); - } -}; - -template <class _FromDuration, class _ToDuration, class _Period> -struct __duration_cast<_FromDuration, _ToDuration, _Period, false, true> -{ - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR - _ToDuration operator()(const _FromDuration& __fd) const - { - typedef typename common_type<typename _ToDuration::rep, typename _FromDuration::rep, intmax_t>::type _Ct; - return _ToDuration(static_cast<typename _ToDuration::rep>( - static_cast<_Ct>(__fd.count()) * static_cast<_Ct>(_Period::num))); - } -}; - -template <class _FromDuration, class _ToDuration, class _Period> -struct __duration_cast<_FromDuration, _ToDuration, _Period, false, false> -{ - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR - _ToDuration operator()(const _FromDuration& __fd) const - { - typedef typename common_type<typename _ToDuration::rep, typename _FromDuration::rep, intmax_t>::type _Ct; - return _ToDuration(static_cast<typename _ToDuration::rep>( - static_cast<_Ct>(__fd.count()) * static_cast<_Ct>(_Period::num) - / static_cast<_Ct>(_Period::den))); - } -}; - -template <class _ToDuration, class _Rep, class _Period> -inline _LIBCPP_INLINE_VISIBILITY -_LIBCPP_CONSTEXPR -typename enable_if -< - __is_duration<_ToDuration>::value, - _ToDuration ->::type -duration_cast(const duration<_Rep, _Period>& __fd) -{ - return __duration_cast<duration<_Rep, _Period>, _ToDuration>()(__fd); -} - -template <class _Rep> -struct _LIBCPP_TEMPLATE_VIS treat_as_floating_point : is_floating_point<_Rep> {}; - -#if _LIBCPP_STD_VER > 14 -template <class _Rep> -inline constexpr bool treat_as_floating_point_v = treat_as_floating_point<_Rep>::value; -#endif - -template <class _Rep> -struct _LIBCPP_TEMPLATE_VIS duration_values -{ -public: +_LIBCPP_BEGIN_NAMESPACE_STD + +namespace chrono +{ + +template <class _Rep, class _Period = ratio<1> > class _LIBCPP_TEMPLATE_VIS duration; + +template <class _Tp> +struct __is_duration : false_type {}; + +template <class _Rep, class _Period> +struct __is_duration<duration<_Rep, _Period> > : true_type {}; + +template <class _Rep, class _Period> +struct __is_duration<const duration<_Rep, _Period> > : true_type {}; + +template <class _Rep, class _Period> +struct __is_duration<volatile duration<_Rep, _Period> > : true_type {}; + +template <class _Rep, class _Period> +struct __is_duration<const volatile duration<_Rep, _Period> > : true_type {}; + +} // chrono + +template <class _Rep1, class _Period1, class _Rep2, class _Period2> +struct _LIBCPP_TEMPLATE_VIS common_type<chrono::duration<_Rep1, _Period1>, + chrono::duration<_Rep2, _Period2> > +{ + typedef chrono::duration<typename common_type<_Rep1, _Rep2>::type, + typename __ratio_gcd<_Period1, _Period2>::type> type; +}; + +namespace chrono { + +// duration_cast + +template <class _FromDuration, class _ToDuration, + class _Period = typename ratio_divide<typename _FromDuration::period, typename _ToDuration::period>::type, + bool = _Period::num == 1, + bool = _Period::den == 1> +struct __duration_cast; + +template <class _FromDuration, class _ToDuration, class _Period> +struct __duration_cast<_FromDuration, _ToDuration, _Period, true, true> +{ + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR + _ToDuration operator()(const _FromDuration& __fd) const + { + return _ToDuration(static_cast<typename _ToDuration::rep>(__fd.count())); + } +}; + +template <class _FromDuration, class _ToDuration, class _Period> +struct __duration_cast<_FromDuration, _ToDuration, _Period, true, false> +{ + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR + _ToDuration operator()(const _FromDuration& __fd) const + { + typedef typename common_type<typename _ToDuration::rep, typename _FromDuration::rep, intmax_t>::type _Ct; + return _ToDuration(static_cast<typename _ToDuration::rep>( + static_cast<_Ct>(__fd.count()) / static_cast<_Ct>(_Period::den))); + } +}; + +template <class _FromDuration, class _ToDuration, class _Period> +struct __duration_cast<_FromDuration, _ToDuration, _Period, false, true> +{ + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR + _ToDuration operator()(const _FromDuration& __fd) const + { + typedef typename common_type<typename _ToDuration::rep, typename _FromDuration::rep, intmax_t>::type _Ct; + return _ToDuration(static_cast<typename _ToDuration::rep>( + static_cast<_Ct>(__fd.count()) * static_cast<_Ct>(_Period::num))); + } +}; + +template <class _FromDuration, class _ToDuration, class _Period> +struct __duration_cast<_FromDuration, _ToDuration, _Period, false, false> +{ + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR + _ToDuration operator()(const _FromDuration& __fd) const + { + typedef typename common_type<typename _ToDuration::rep, typename _FromDuration::rep, intmax_t>::type _Ct; + return _ToDuration(static_cast<typename _ToDuration::rep>( + static_cast<_Ct>(__fd.count()) * static_cast<_Ct>(_Period::num) + / static_cast<_Ct>(_Period::den))); + } +}; + +template <class _ToDuration, class _Rep, class _Period> +inline _LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR +typename enable_if +< + __is_duration<_ToDuration>::value, + _ToDuration +>::type +duration_cast(const duration<_Rep, _Period>& __fd) +{ + return __duration_cast<duration<_Rep, _Period>, _ToDuration>()(__fd); +} + +template <class _Rep> +struct _LIBCPP_TEMPLATE_VIS treat_as_floating_point : is_floating_point<_Rep> {}; + +#if _LIBCPP_STD_VER > 14 +template <class _Rep> +inline constexpr bool treat_as_floating_point_v = treat_as_floating_point<_Rep>::value; +#endif + +template <class _Rep> +struct _LIBCPP_TEMPLATE_VIS duration_values +{ +public: _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR _Rep zero() _NOEXCEPT {return _Rep(0);} _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR _Rep max() _NOEXCEPT {return numeric_limits<_Rep>::max();} _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR _Rep min() _NOEXCEPT {return numeric_limits<_Rep>::lowest();} -}; - -#if _LIBCPP_STD_VER > 14 -template <class _ToDuration, class _Rep, class _Period> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR -typename enable_if -< - __is_duration<_ToDuration>::value, - _ToDuration ->::type -floor(const duration<_Rep, _Period>& __d) -{ - _ToDuration __t = duration_cast<_ToDuration>(__d); - if (__t > __d) - __t = __t - _ToDuration{1}; - return __t; -} - -template <class _ToDuration, class _Rep, class _Period> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR -typename enable_if -< - __is_duration<_ToDuration>::value, - _ToDuration ->::type -ceil(const duration<_Rep, _Period>& __d) -{ - _ToDuration __t = duration_cast<_ToDuration>(__d); - if (__t < __d) - __t = __t + _ToDuration{1}; - return __t; -} - -template <class _ToDuration, class _Rep, class _Period> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR -typename enable_if -< - __is_duration<_ToDuration>::value, - _ToDuration ->::type -round(const duration<_Rep, _Period>& __d) -{ - _ToDuration __lower = floor<_ToDuration>(__d); - _ToDuration __upper = __lower + _ToDuration{1}; - auto __lowerDiff = __d - __lower; - auto __upperDiff = __upper - __d; - if (__lowerDiff < __upperDiff) - return __lower; - if (__lowerDiff > __upperDiff) - return __upper; - return __lower.count() & 1 ? __upper : __lower; -} -#endif - -// duration - -template <class _Rep, class _Period> -class _LIBCPP_TEMPLATE_VIS duration -{ - static_assert(!__is_duration<_Rep>::value, "A duration representation can not be a duration"); - static_assert(__is_ratio<_Period>::value, "Second template parameter of duration must be a std::ratio"); - static_assert(_Period::num > 0, "duration period must be positive"); - - template <class _R1, class _R2> - struct __no_overflow - { - private: - static const intmax_t __gcd_n1_n2 = __static_gcd<_R1::num, _R2::num>::value; - static const intmax_t __gcd_d1_d2 = __static_gcd<_R1::den, _R2::den>::value; - static const intmax_t __n1 = _R1::num / __gcd_n1_n2; - static const intmax_t __d1 = _R1::den / __gcd_d1_d2; - static const intmax_t __n2 = _R2::num / __gcd_n1_n2; - static const intmax_t __d2 = _R2::den / __gcd_d1_d2; - static const intmax_t max = -((intmax_t(1) << (sizeof(intmax_t) * CHAR_BIT - 1)) + 1); - - template <intmax_t _Xp, intmax_t _Yp, bool __overflow> - struct __mul // __overflow == false - { - static const intmax_t value = _Xp * _Yp; - }; - - template <intmax_t _Xp, intmax_t _Yp> - struct __mul<_Xp, _Yp, true> - { - static const intmax_t value = 1; - }; - - public: - static const bool value = (__n1 <= max / __d2) && (__n2 <= max / __d1); - typedef ratio<__mul<__n1, __d2, !value>::value, - __mul<__n2, __d1, !value>::value> type; - }; - -public: - typedef _Rep rep; - typedef typename _Period::type period; -private: - rep __rep_; -public: - - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR +}; + +#if _LIBCPP_STD_VER > 14 +template <class _ToDuration, class _Rep, class _Period> +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR +typename enable_if +< + __is_duration<_ToDuration>::value, + _ToDuration +>::type +floor(const duration<_Rep, _Period>& __d) +{ + _ToDuration __t = duration_cast<_ToDuration>(__d); + if (__t > __d) + __t = __t - _ToDuration{1}; + return __t; +} + +template <class _ToDuration, class _Rep, class _Period> +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR +typename enable_if +< + __is_duration<_ToDuration>::value, + _ToDuration +>::type +ceil(const duration<_Rep, _Period>& __d) +{ + _ToDuration __t = duration_cast<_ToDuration>(__d); + if (__t < __d) + __t = __t + _ToDuration{1}; + return __t; +} + +template <class _ToDuration, class _Rep, class _Period> +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR +typename enable_if +< + __is_duration<_ToDuration>::value, + _ToDuration +>::type +round(const duration<_Rep, _Period>& __d) +{ + _ToDuration __lower = floor<_ToDuration>(__d); + _ToDuration __upper = __lower + _ToDuration{1}; + auto __lowerDiff = __d - __lower; + auto __upperDiff = __upper - __d; + if (__lowerDiff < __upperDiff) + return __lower; + if (__lowerDiff > __upperDiff) + return __upper; + return __lower.count() & 1 ? __upper : __lower; +} +#endif + +// duration + +template <class _Rep, class _Period> +class _LIBCPP_TEMPLATE_VIS duration +{ + static_assert(!__is_duration<_Rep>::value, "A duration representation can not be a duration"); + static_assert(__is_ratio<_Period>::value, "Second template parameter of duration must be a std::ratio"); + static_assert(_Period::num > 0, "duration period must be positive"); + + template <class _R1, class _R2> + struct __no_overflow + { + private: + static const intmax_t __gcd_n1_n2 = __static_gcd<_R1::num, _R2::num>::value; + static const intmax_t __gcd_d1_d2 = __static_gcd<_R1::den, _R2::den>::value; + static const intmax_t __n1 = _R1::num / __gcd_n1_n2; + static const intmax_t __d1 = _R1::den / __gcd_d1_d2; + static const intmax_t __n2 = _R2::num / __gcd_n1_n2; + static const intmax_t __d2 = _R2::den / __gcd_d1_d2; + static const intmax_t max = -((intmax_t(1) << (sizeof(intmax_t) * CHAR_BIT - 1)) + 1); + + template <intmax_t _Xp, intmax_t _Yp, bool __overflow> + struct __mul // __overflow == false + { + static const intmax_t value = _Xp * _Yp; + }; + + template <intmax_t _Xp, intmax_t _Yp> + struct __mul<_Xp, _Yp, true> + { + static const intmax_t value = 1; + }; + + public: + static const bool value = (__n1 <= max / __d2) && (__n2 <= max / __d1); + typedef ratio<__mul<__n1, __d2, !value>::value, + __mul<__n2, __d1, !value>::value> type; + }; + +public: + typedef _Rep rep; + typedef typename _Period::type period; +private: + rep __rep_; +public: + + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR #ifndef _LIBCPP_CXX03_LANG - duration() = default; -#else - duration() {} -#endif - - template <class _Rep2> - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR - explicit duration(const _Rep2& __r, - typename enable_if - < - is_convertible<_Rep2, rep>::value && - (treat_as_floating_point<rep>::value || - !treat_as_floating_point<_Rep2>::value) - >::type* = nullptr) - : __rep_(__r) {} - - // conversions - template <class _Rep2, class _Period2> - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR - duration(const duration<_Rep2, _Period2>& __d, - typename enable_if - < - __no_overflow<_Period2, period>::value && ( - treat_as_floating_point<rep>::value || - (__no_overflow<_Period2, period>::type::den == 1 && - !treat_as_floating_point<_Rep2>::value)) - >::type* = nullptr) - : __rep_(chrono::duration_cast<duration>(__d).count()) {} - - // observer - - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR rep count() const {return __rep_;} - - // arithmetic - - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR typename common_type<duration>::type operator+() const {return typename common_type<duration>::type(*this);} - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR typename common_type<duration>::type operator-() const {return typename common_type<duration>::type(-__rep_);} - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator++() {++__rep_; return *this;} - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration operator++(int) {return duration(__rep_++);} - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator--() {--__rep_; return *this;} - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration operator--(int) {return duration(__rep_--);} - - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator+=(const duration& __d) {__rep_ += __d.count(); return *this;} - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator-=(const duration& __d) {__rep_ -= __d.count(); return *this;} - - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator*=(const rep& rhs) {__rep_ *= rhs; return *this;} - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator/=(const rep& rhs) {__rep_ /= rhs; return *this;} - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator%=(const rep& rhs) {__rep_ %= rhs; return *this;} - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator%=(const duration& rhs) {__rep_ %= rhs.count(); return *this;} - - // special values - + duration() = default; +#else + duration() {} +#endif + + template <class _Rep2> + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR + explicit duration(const _Rep2& __r, + typename enable_if + < + is_convertible<_Rep2, rep>::value && + (treat_as_floating_point<rep>::value || + !treat_as_floating_point<_Rep2>::value) + >::type* = nullptr) + : __rep_(__r) {} + + // conversions + template <class _Rep2, class _Period2> + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR + duration(const duration<_Rep2, _Period2>& __d, + typename enable_if + < + __no_overflow<_Period2, period>::value && ( + treat_as_floating_point<rep>::value || + (__no_overflow<_Period2, period>::type::den == 1 && + !treat_as_floating_point<_Rep2>::value)) + >::type* = nullptr) + : __rep_(chrono::duration_cast<duration>(__d).count()) {} + + // observer + + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR rep count() const {return __rep_;} + + // arithmetic + + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR typename common_type<duration>::type operator+() const {return typename common_type<duration>::type(*this);} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR typename common_type<duration>::type operator-() const {return typename common_type<duration>::type(-__rep_);} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator++() {++__rep_; return *this;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration operator++(int) {return duration(__rep_++);} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator--() {--__rep_; return *this;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration operator--(int) {return duration(__rep_--);} + + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator+=(const duration& __d) {__rep_ += __d.count(); return *this;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator-=(const duration& __d) {__rep_ -= __d.count(); return *this;} + + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator*=(const rep& rhs) {__rep_ *= rhs; return *this;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator/=(const rep& rhs) {__rep_ /= rhs; return *this;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator%=(const rep& rhs) {__rep_ %= rhs; return *this;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator%=(const duration& rhs) {__rep_ %= rhs.count(); return *this;} + + // special values + _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR duration zero() _NOEXCEPT {return duration(duration_values<rep>::zero());} _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR duration min() _NOEXCEPT {return duration(duration_values<rep>::min());} _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR duration max() _NOEXCEPT {return duration(duration_values<rep>::max());} -}; - -typedef duration<long long, nano> nanoseconds; -typedef duration<long long, micro> microseconds; -typedef duration<long long, milli> milliseconds; -typedef duration<long long > seconds; -typedef duration< long, ratio< 60> > minutes; -typedef duration< long, ratio<3600> > hours; +}; + +typedef duration<long long, nano> nanoseconds; +typedef duration<long long, micro> microseconds; +typedef duration<long long, milli> milliseconds; +typedef duration<long long > seconds; +typedef duration< long, ratio< 60> > minutes; +typedef duration< long, ratio<3600> > hours; #if _LIBCPP_STD_VER > 17 typedef duration< int, ratio_multiply<ratio<24>, hours::period>> days; typedef duration< int, ratio_multiply<ratio<7>, days::period>> weeks; typedef duration< int, ratio_multiply<ratio<146097, 400>, days::period>> years; typedef duration< int, ratio_divide<years::period, ratio<12>>> months; #endif -// Duration == - -template <class _LhsDuration, class _RhsDuration> -struct __duration_eq -{ - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR - bool operator()(const _LhsDuration& __lhs, const _RhsDuration& __rhs) const - { - typedef typename common_type<_LhsDuration, _RhsDuration>::type _Ct; - return _Ct(__lhs).count() == _Ct(__rhs).count(); - } -}; - -template <class _LhsDuration> -struct __duration_eq<_LhsDuration, _LhsDuration> -{ - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR - bool operator()(const _LhsDuration& __lhs, const _LhsDuration& __rhs) const - {return __lhs.count() == __rhs.count();} -}; - -template <class _Rep1, class _Period1, class _Rep2, class _Period2> -inline _LIBCPP_INLINE_VISIBILITY -_LIBCPP_CONSTEXPR -bool -operator==(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) -{ - return __duration_eq<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >()(__lhs, __rhs); -} - -// Duration != - -template <class _Rep1, class _Period1, class _Rep2, class _Period2> -inline _LIBCPP_INLINE_VISIBILITY -_LIBCPP_CONSTEXPR -bool -operator!=(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) -{ - return !(__lhs == __rhs); -} - -// Duration < - -template <class _LhsDuration, class _RhsDuration> -struct __duration_lt -{ - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR - bool operator()(const _LhsDuration& __lhs, const _RhsDuration& __rhs) const - { - typedef typename common_type<_LhsDuration, _RhsDuration>::type _Ct; - return _Ct(__lhs).count() < _Ct(__rhs).count(); - } -}; - -template <class _LhsDuration> -struct __duration_lt<_LhsDuration, _LhsDuration> -{ - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR - bool operator()(const _LhsDuration& __lhs, const _LhsDuration& __rhs) const - {return __lhs.count() < __rhs.count();} -}; - -template <class _Rep1, class _Period1, class _Rep2, class _Period2> -inline _LIBCPP_INLINE_VISIBILITY -_LIBCPP_CONSTEXPR -bool -operator< (const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) -{ - return __duration_lt<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >()(__lhs, __rhs); -} - -// Duration > - -template <class _Rep1, class _Period1, class _Rep2, class _Period2> -inline _LIBCPP_INLINE_VISIBILITY -_LIBCPP_CONSTEXPR -bool -operator> (const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) -{ - return __rhs < __lhs; -} - -// Duration <= - -template <class _Rep1, class _Period1, class _Rep2, class _Period2> -inline _LIBCPP_INLINE_VISIBILITY -_LIBCPP_CONSTEXPR -bool -operator<=(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) -{ - return !(__rhs < __lhs); -} - -// Duration >= - -template <class _Rep1, class _Period1, class _Rep2, class _Period2> -inline _LIBCPP_INLINE_VISIBILITY -_LIBCPP_CONSTEXPR -bool -operator>=(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) -{ - return !(__lhs < __rhs); -} - -// Duration + - -template <class _Rep1, class _Period1, class _Rep2, class _Period2> -inline _LIBCPP_INLINE_VISIBILITY -_LIBCPP_CONSTEXPR -typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type -operator+(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) -{ - typedef typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type _Cd; - return _Cd(_Cd(__lhs).count() + _Cd(__rhs).count()); -} - -// Duration - - -template <class _Rep1, class _Period1, class _Rep2, class _Period2> -inline _LIBCPP_INLINE_VISIBILITY -_LIBCPP_CONSTEXPR -typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type -operator-(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) -{ - typedef typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type _Cd; - return _Cd(_Cd(__lhs).count() - _Cd(__rhs).count()); -} - -// Duration * - -template <class _Rep1, class _Period, class _Rep2> -inline _LIBCPP_INLINE_VISIBILITY -_LIBCPP_CONSTEXPR -typename enable_if -< - is_convertible<_Rep2, typename common_type<_Rep1, _Rep2>::type>::value, - duration<typename common_type<_Rep1, _Rep2>::type, _Period> ->::type -operator*(const duration<_Rep1, _Period>& __d, const _Rep2& __s) -{ - typedef typename common_type<_Rep1, _Rep2>::type _Cr; - typedef duration<_Cr, _Period> _Cd; - return _Cd(_Cd(__d).count() * static_cast<_Cr>(__s)); -} - -template <class _Rep1, class _Period, class _Rep2> -inline _LIBCPP_INLINE_VISIBILITY -_LIBCPP_CONSTEXPR -typename enable_if -< - is_convertible<_Rep1, typename common_type<_Rep1, _Rep2>::type>::value, - duration<typename common_type<_Rep1, _Rep2>::type, _Period> ->::type -operator*(const _Rep1& __s, const duration<_Rep2, _Period>& __d) -{ - return __d * __s; -} - -// Duration / - -template <class _Rep1, class _Period, class _Rep2> -inline _LIBCPP_INLINE_VISIBILITY -_LIBCPP_CONSTEXPR -typename enable_if -< - !__is_duration<_Rep2>::value && - is_convertible<_Rep2, typename common_type<_Rep1, _Rep2>::type>::value, - duration<typename common_type<_Rep1, _Rep2>::type, _Period> ->::type -operator/(const duration<_Rep1, _Period>& __d, const _Rep2& __s) -{ - typedef typename common_type<_Rep1, _Rep2>::type _Cr; - typedef duration<_Cr, _Period> _Cd; - return _Cd(_Cd(__d).count() / static_cast<_Cr>(__s)); -} - -template <class _Rep1, class _Period1, class _Rep2, class _Period2> -inline _LIBCPP_INLINE_VISIBILITY -_LIBCPP_CONSTEXPR -typename common_type<_Rep1, _Rep2>::type -operator/(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) -{ - typedef typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type _Ct; - return _Ct(__lhs).count() / _Ct(__rhs).count(); -} - -// Duration % - -template <class _Rep1, class _Period, class _Rep2> -inline _LIBCPP_INLINE_VISIBILITY -_LIBCPP_CONSTEXPR -typename enable_if -< - !__is_duration<_Rep2>::value && - is_convertible<_Rep2, typename common_type<_Rep1, _Rep2>::type>::value, - duration<typename common_type<_Rep1, _Rep2>::type, _Period> ->::type -operator%(const duration<_Rep1, _Period>& __d, const _Rep2& __s) -{ - typedef typename common_type<_Rep1, _Rep2>::type _Cr; - typedef duration<_Cr, _Period> _Cd; - return _Cd(_Cd(__d).count() % static_cast<_Cr>(__s)); -} - -template <class _Rep1, class _Period1, class _Rep2, class _Period2> -inline _LIBCPP_INLINE_VISIBILITY -_LIBCPP_CONSTEXPR -typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type -operator%(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) -{ - typedef typename common_type<_Rep1, _Rep2>::type _Cr; - typedef typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type _Cd; - return _Cd(static_cast<_Cr>(_Cd(__lhs).count()) % static_cast<_Cr>(_Cd(__rhs).count())); -} - -////////////////////////////////////////////////////////// -///////////////////// time_point ///////////////////////// -////////////////////////////////////////////////////////// - -template <class _Clock, class _Duration = typename _Clock::duration> -class _LIBCPP_TEMPLATE_VIS time_point -{ - static_assert(__is_duration<_Duration>::value, - "Second template parameter of time_point must be a std::chrono::duration"); -public: - typedef _Clock clock; - typedef _Duration duration; - typedef typename duration::rep rep; - typedef typename duration::period period; -private: - duration __d_; - -public: - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 time_point() : __d_(duration::zero()) {} - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 explicit time_point(const duration& __d) : __d_(__d) {} - - // conversions - template <class _Duration2> - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 - time_point(const time_point<clock, _Duration2>& t, - typename enable_if - < - is_convertible<_Duration2, duration>::value - >::type* = nullptr) - : __d_(t.time_since_epoch()) {} - - // observer - - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 duration time_since_epoch() const {return __d_;} - - // arithmetic - +// Duration == + +template <class _LhsDuration, class _RhsDuration> +struct __duration_eq +{ + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR + bool operator()(const _LhsDuration& __lhs, const _RhsDuration& __rhs) const + { + typedef typename common_type<_LhsDuration, _RhsDuration>::type _Ct; + return _Ct(__lhs).count() == _Ct(__rhs).count(); + } +}; + +template <class _LhsDuration> +struct __duration_eq<_LhsDuration, _LhsDuration> +{ + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR + bool operator()(const _LhsDuration& __lhs, const _LhsDuration& __rhs) const + {return __lhs.count() == __rhs.count();} +}; + +template <class _Rep1, class _Period1, class _Rep2, class _Period2> +inline _LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR +bool +operator==(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) +{ + return __duration_eq<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >()(__lhs, __rhs); +} + +// Duration != + +template <class _Rep1, class _Period1, class _Rep2, class _Period2> +inline _LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR +bool +operator!=(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) +{ + return !(__lhs == __rhs); +} + +// Duration < + +template <class _LhsDuration, class _RhsDuration> +struct __duration_lt +{ + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR + bool operator()(const _LhsDuration& __lhs, const _RhsDuration& __rhs) const + { + typedef typename common_type<_LhsDuration, _RhsDuration>::type _Ct; + return _Ct(__lhs).count() < _Ct(__rhs).count(); + } +}; + +template <class _LhsDuration> +struct __duration_lt<_LhsDuration, _LhsDuration> +{ + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR + bool operator()(const _LhsDuration& __lhs, const _LhsDuration& __rhs) const + {return __lhs.count() < __rhs.count();} +}; + +template <class _Rep1, class _Period1, class _Rep2, class _Period2> +inline _LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR +bool +operator< (const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) +{ + return __duration_lt<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >()(__lhs, __rhs); +} + +// Duration > + +template <class _Rep1, class _Period1, class _Rep2, class _Period2> +inline _LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR +bool +operator> (const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) +{ + return __rhs < __lhs; +} + +// Duration <= + +template <class _Rep1, class _Period1, class _Rep2, class _Period2> +inline _LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR +bool +operator<=(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) +{ + return !(__rhs < __lhs); +} + +// Duration >= + +template <class _Rep1, class _Period1, class _Rep2, class _Period2> +inline _LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR +bool +operator>=(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) +{ + return !(__lhs < __rhs); +} + +// Duration + + +template <class _Rep1, class _Period1, class _Rep2, class _Period2> +inline _LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR +typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type +operator+(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) +{ + typedef typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type _Cd; + return _Cd(_Cd(__lhs).count() + _Cd(__rhs).count()); +} + +// Duration - + +template <class _Rep1, class _Period1, class _Rep2, class _Period2> +inline _LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR +typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type +operator-(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) +{ + typedef typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type _Cd; + return _Cd(_Cd(__lhs).count() - _Cd(__rhs).count()); +} + +// Duration * + +template <class _Rep1, class _Period, class _Rep2> +inline _LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR +typename enable_if +< + is_convertible<_Rep2, typename common_type<_Rep1, _Rep2>::type>::value, + duration<typename common_type<_Rep1, _Rep2>::type, _Period> +>::type +operator*(const duration<_Rep1, _Period>& __d, const _Rep2& __s) +{ + typedef typename common_type<_Rep1, _Rep2>::type _Cr; + typedef duration<_Cr, _Period> _Cd; + return _Cd(_Cd(__d).count() * static_cast<_Cr>(__s)); +} + +template <class _Rep1, class _Period, class _Rep2> +inline _LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR +typename enable_if +< + is_convertible<_Rep1, typename common_type<_Rep1, _Rep2>::type>::value, + duration<typename common_type<_Rep1, _Rep2>::type, _Period> +>::type +operator*(const _Rep1& __s, const duration<_Rep2, _Period>& __d) +{ + return __d * __s; +} + +// Duration / + +template <class _Rep1, class _Period, class _Rep2> +inline _LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR +typename enable_if +< + !__is_duration<_Rep2>::value && + is_convertible<_Rep2, typename common_type<_Rep1, _Rep2>::type>::value, + duration<typename common_type<_Rep1, _Rep2>::type, _Period> +>::type +operator/(const duration<_Rep1, _Period>& __d, const _Rep2& __s) +{ + typedef typename common_type<_Rep1, _Rep2>::type _Cr; + typedef duration<_Cr, _Period> _Cd; + return _Cd(_Cd(__d).count() / static_cast<_Cr>(__s)); +} + +template <class _Rep1, class _Period1, class _Rep2, class _Period2> +inline _LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR +typename common_type<_Rep1, _Rep2>::type +operator/(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) +{ + typedef typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type _Ct; + return _Ct(__lhs).count() / _Ct(__rhs).count(); +} + +// Duration % + +template <class _Rep1, class _Period, class _Rep2> +inline _LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR +typename enable_if +< + !__is_duration<_Rep2>::value && + is_convertible<_Rep2, typename common_type<_Rep1, _Rep2>::type>::value, + duration<typename common_type<_Rep1, _Rep2>::type, _Period> +>::type +operator%(const duration<_Rep1, _Period>& __d, const _Rep2& __s) +{ + typedef typename common_type<_Rep1, _Rep2>::type _Cr; + typedef duration<_Cr, _Period> _Cd; + return _Cd(_Cd(__d).count() % static_cast<_Cr>(__s)); +} + +template <class _Rep1, class _Period1, class _Rep2, class _Period2> +inline _LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR +typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type +operator%(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) +{ + typedef typename common_type<_Rep1, _Rep2>::type _Cr; + typedef typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type _Cd; + return _Cd(static_cast<_Cr>(_Cd(__lhs).count()) % static_cast<_Cr>(_Cd(__rhs).count())); +} + +////////////////////////////////////////////////////////// +///////////////////// time_point ///////////////////////// +////////////////////////////////////////////////////////// + +template <class _Clock, class _Duration = typename _Clock::duration> +class _LIBCPP_TEMPLATE_VIS time_point +{ + static_assert(__is_duration<_Duration>::value, + "Second template parameter of time_point must be a std::chrono::duration"); +public: + typedef _Clock clock; + typedef _Duration duration; + typedef typename duration::rep rep; + typedef typename duration::period period; +private: + duration __d_; + +public: + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 time_point() : __d_(duration::zero()) {} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 explicit time_point(const duration& __d) : __d_(__d) {} + + // conversions + template <class _Duration2> + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 + time_point(const time_point<clock, _Duration2>& t, + typename enable_if + < + is_convertible<_Duration2, duration>::value + >::type* = nullptr) + : __d_(t.time_since_epoch()) {} + + // observer + + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 duration time_since_epoch() const {return __d_;} + + // arithmetic + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 time_point& operator+=(const duration& __d) {__d_ += __d; return *this;} _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 time_point& operator-=(const duration& __d) {__d_ -= __d; return *this;} - - // special values - + + // special values + _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR time_point min() _NOEXCEPT {return time_point(duration::min());} _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR time_point max() _NOEXCEPT {return time_point(duration::max());} -}; - -} // chrono - -template <class _Clock, class _Duration1, class _Duration2> -struct _LIBCPP_TEMPLATE_VIS common_type<chrono::time_point<_Clock, _Duration1>, - chrono::time_point<_Clock, _Duration2> > -{ - typedef chrono::time_point<_Clock, typename common_type<_Duration1, _Duration2>::type> type; -}; - -namespace chrono { - -template <class _ToDuration, class _Clock, class _Duration> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 -time_point<_Clock, _ToDuration> -time_point_cast(const time_point<_Clock, _Duration>& __t) -{ - return time_point<_Clock, _ToDuration>(chrono::duration_cast<_ToDuration>(__t.time_since_epoch())); -} - -#if _LIBCPP_STD_VER > 14 -template <class _ToDuration, class _Clock, class _Duration> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR -typename enable_if -< - __is_duration<_ToDuration>::value, - time_point<_Clock, _ToDuration> ->::type -floor(const time_point<_Clock, _Duration>& __t) -{ - return time_point<_Clock, _ToDuration>{floor<_ToDuration>(__t.time_since_epoch())}; -} - -template <class _ToDuration, class _Clock, class _Duration> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR -typename enable_if -< - __is_duration<_ToDuration>::value, - time_point<_Clock, _ToDuration> ->::type -ceil(const time_point<_Clock, _Duration>& __t) -{ - return time_point<_Clock, _ToDuration>{ceil<_ToDuration>(__t.time_since_epoch())}; -} - -template <class _ToDuration, class _Clock, class _Duration> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR -typename enable_if -< - __is_duration<_ToDuration>::value, - time_point<_Clock, _ToDuration> ->::type -round(const time_point<_Clock, _Duration>& __t) -{ - return time_point<_Clock, _ToDuration>{round<_ToDuration>(__t.time_since_epoch())}; -} - -template <class _Rep, class _Period> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR -typename enable_if -< - numeric_limits<_Rep>::is_signed, - duration<_Rep, _Period> ->::type -abs(duration<_Rep, _Period> __d) -{ - return __d >= __d.zero() ? +__d : -__d; -} -#endif - -// time_point == - -template <class _Clock, class _Duration1, class _Duration2> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 -bool -operator==(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs) -{ - return __lhs.time_since_epoch() == __rhs.time_since_epoch(); -} - -// time_point != - -template <class _Clock, class _Duration1, class _Duration2> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 -bool -operator!=(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs) -{ - return !(__lhs == __rhs); -} - -// time_point < - -template <class _Clock, class _Duration1, class _Duration2> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 -bool -operator<(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs) -{ - return __lhs.time_since_epoch() < __rhs.time_since_epoch(); -} - -// time_point > - -template <class _Clock, class _Duration1, class _Duration2> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 -bool -operator>(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs) -{ - return __rhs < __lhs; -} - -// time_point <= - -template <class _Clock, class _Duration1, class _Duration2> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 -bool -operator<=(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs) -{ - return !(__rhs < __lhs); -} - -// time_point >= - -template <class _Clock, class _Duration1, class _Duration2> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 -bool -operator>=(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs) -{ - return !(__lhs < __rhs); -} - -// time_point operator+(time_point x, duration y); - -template <class _Clock, class _Duration1, class _Rep2, class _Period2> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 -time_point<_Clock, typename common_type<_Duration1, duration<_Rep2, _Period2> >::type> -operator+(const time_point<_Clock, _Duration1>& __lhs, const duration<_Rep2, _Period2>& __rhs) -{ - typedef time_point<_Clock, typename common_type<_Duration1, duration<_Rep2, _Period2> >::type> _Tr; - return _Tr (__lhs.time_since_epoch() + __rhs); -} - -// time_point operator+(duration x, time_point y); - -template <class _Rep1, class _Period1, class _Clock, class _Duration2> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 -time_point<_Clock, typename common_type<duration<_Rep1, _Period1>, _Duration2>::type> -operator+(const duration<_Rep1, _Period1>& __lhs, const time_point<_Clock, _Duration2>& __rhs) -{ - return __rhs + __lhs; -} - -// time_point operator-(time_point x, duration y); - -template <class _Clock, class _Duration1, class _Rep2, class _Period2> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 -time_point<_Clock, typename common_type<_Duration1, duration<_Rep2, _Period2> >::type> -operator-(const time_point<_Clock, _Duration1>& __lhs, const duration<_Rep2, _Period2>& __rhs) -{ +}; + +} // chrono + +template <class _Clock, class _Duration1, class _Duration2> +struct _LIBCPP_TEMPLATE_VIS common_type<chrono::time_point<_Clock, _Duration1>, + chrono::time_point<_Clock, _Duration2> > +{ + typedef chrono::time_point<_Clock, typename common_type<_Duration1, _Duration2>::type> type; +}; + +namespace chrono { + +template <class _ToDuration, class _Clock, class _Duration> +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 +time_point<_Clock, _ToDuration> +time_point_cast(const time_point<_Clock, _Duration>& __t) +{ + return time_point<_Clock, _ToDuration>(chrono::duration_cast<_ToDuration>(__t.time_since_epoch())); +} + +#if _LIBCPP_STD_VER > 14 +template <class _ToDuration, class _Clock, class _Duration> +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR +typename enable_if +< + __is_duration<_ToDuration>::value, + time_point<_Clock, _ToDuration> +>::type +floor(const time_point<_Clock, _Duration>& __t) +{ + return time_point<_Clock, _ToDuration>{floor<_ToDuration>(__t.time_since_epoch())}; +} + +template <class _ToDuration, class _Clock, class _Duration> +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR +typename enable_if +< + __is_duration<_ToDuration>::value, + time_point<_Clock, _ToDuration> +>::type +ceil(const time_point<_Clock, _Duration>& __t) +{ + return time_point<_Clock, _ToDuration>{ceil<_ToDuration>(__t.time_since_epoch())}; +} + +template <class _ToDuration, class _Clock, class _Duration> +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR +typename enable_if +< + __is_duration<_ToDuration>::value, + time_point<_Clock, _ToDuration> +>::type +round(const time_point<_Clock, _Duration>& __t) +{ + return time_point<_Clock, _ToDuration>{round<_ToDuration>(__t.time_since_epoch())}; +} + +template <class _Rep, class _Period> +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR +typename enable_if +< + numeric_limits<_Rep>::is_signed, + duration<_Rep, _Period> +>::type +abs(duration<_Rep, _Period> __d) +{ + return __d >= __d.zero() ? +__d : -__d; +} +#endif + +// time_point == + +template <class _Clock, class _Duration1, class _Duration2> +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 +bool +operator==(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs) +{ + return __lhs.time_since_epoch() == __rhs.time_since_epoch(); +} + +// time_point != + +template <class _Clock, class _Duration1, class _Duration2> +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 +bool +operator!=(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs) +{ + return !(__lhs == __rhs); +} + +// time_point < + +template <class _Clock, class _Duration1, class _Duration2> +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 +bool +operator<(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs) +{ + return __lhs.time_since_epoch() < __rhs.time_since_epoch(); +} + +// time_point > + +template <class _Clock, class _Duration1, class _Duration2> +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 +bool +operator>(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs) +{ + return __rhs < __lhs; +} + +// time_point <= + +template <class _Clock, class _Duration1, class _Duration2> +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 +bool +operator<=(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs) +{ + return !(__rhs < __lhs); +} + +// time_point >= + +template <class _Clock, class _Duration1, class _Duration2> +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 +bool +operator>=(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs) +{ + return !(__lhs < __rhs); +} + +// time_point operator+(time_point x, duration y); + +template <class _Clock, class _Duration1, class _Rep2, class _Period2> +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 +time_point<_Clock, typename common_type<_Duration1, duration<_Rep2, _Period2> >::type> +operator+(const time_point<_Clock, _Duration1>& __lhs, const duration<_Rep2, _Period2>& __rhs) +{ + typedef time_point<_Clock, typename common_type<_Duration1, duration<_Rep2, _Period2> >::type> _Tr; + return _Tr (__lhs.time_since_epoch() + __rhs); +} + +// time_point operator+(duration x, time_point y); + +template <class _Rep1, class _Period1, class _Clock, class _Duration2> +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 +time_point<_Clock, typename common_type<duration<_Rep1, _Period1>, _Duration2>::type> +operator+(const duration<_Rep1, _Period1>& __lhs, const time_point<_Clock, _Duration2>& __rhs) +{ + return __rhs + __lhs; +} + +// time_point operator-(time_point x, duration y); + +template <class _Clock, class _Duration1, class _Rep2, class _Period2> +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 +time_point<_Clock, typename common_type<_Duration1, duration<_Rep2, _Period2> >::type> +operator-(const time_point<_Clock, _Duration1>& __lhs, const duration<_Rep2, _Period2>& __rhs) +{ typedef time_point<_Clock, typename common_type<_Duration1, duration<_Rep2, _Period2> >::type> _Ret; return _Ret(__lhs.time_since_epoch() -__rhs); -} - -// duration operator-(time_point x, time_point y); - -template <class _Clock, class _Duration1, class _Duration2> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 -typename common_type<_Duration1, _Duration2>::type -operator-(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs) -{ - return __lhs.time_since_epoch() - __rhs.time_since_epoch(); -} - -////////////////////////////////////////////////////////// -/////////////////////// clocks /////////////////////////// -////////////////////////////////////////////////////////// - -class _LIBCPP_TYPE_VIS system_clock -{ -public: - typedef microseconds duration; - typedef duration::rep rep; - typedef duration::period period; - typedef chrono::time_point<system_clock> time_point; - static _LIBCPP_CONSTEXPR_AFTER_CXX11 const bool is_steady = false; - - static time_point now() _NOEXCEPT; - static time_t to_time_t (const time_point& __t) _NOEXCEPT; - static time_point from_time_t(time_t __t) _NOEXCEPT; -}; - -#ifndef _LIBCPP_HAS_NO_MONOTONIC_CLOCK -class _LIBCPP_TYPE_VIS steady_clock -{ -public: - typedef nanoseconds duration; - typedef duration::rep rep; - typedef duration::period period; - typedef chrono::time_point<steady_clock, duration> time_point; - static _LIBCPP_CONSTEXPR_AFTER_CXX11 const bool is_steady = true; - - static time_point now() _NOEXCEPT; -}; - -typedef steady_clock high_resolution_clock; -#else -typedef system_clock high_resolution_clock; -#endif - +} + +// duration operator-(time_point x, time_point y); + +template <class _Clock, class _Duration1, class _Duration2> +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 +typename common_type<_Duration1, _Duration2>::type +operator-(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs) +{ + return __lhs.time_since_epoch() - __rhs.time_since_epoch(); +} + +////////////////////////////////////////////////////////// +/////////////////////// clocks /////////////////////////// +////////////////////////////////////////////////////////// + +class _LIBCPP_TYPE_VIS system_clock +{ +public: + typedef microseconds duration; + typedef duration::rep rep; + typedef duration::period period; + typedef chrono::time_point<system_clock> time_point; + static _LIBCPP_CONSTEXPR_AFTER_CXX11 const bool is_steady = false; + + static time_point now() _NOEXCEPT; + static time_t to_time_t (const time_point& __t) _NOEXCEPT; + static time_point from_time_t(time_t __t) _NOEXCEPT; +}; + +#ifndef _LIBCPP_HAS_NO_MONOTONIC_CLOCK +class _LIBCPP_TYPE_VIS steady_clock +{ +public: + typedef nanoseconds duration; + typedef duration::rep rep; + typedef duration::period period; + typedef chrono::time_point<steady_clock, duration> time_point; + static _LIBCPP_CONSTEXPR_AFTER_CXX11 const bool is_steady = true; + + static time_point now() _NOEXCEPT; +}; + +typedef steady_clock high_resolution_clock; +#else +typedef system_clock high_resolution_clock; +#endif + #if _LIBCPP_STD_VER > 17 // [time.clock.file], type file_clock using file_clock = _VSTD_FS::_FilesystemClock; @@ -1626,9 +1626,9 @@ using local_seconds = local_time<seconds>; using local_days = local_time<days>; -struct last_spec { explicit last_spec() = default; }; +struct last_spec { explicit last_spec() = default; }; -class day { +class day { private: unsigned char __d; public: @@ -1693,7 +1693,7 @@ inline constexpr day& day::operator-=(const days& __dd) noexcept { *this = *this - __dd; return *this; } -class month { +class month { private: unsigned char __m; public: @@ -1764,21 +1764,21 @@ inline constexpr month& month::operator-=(const months& __dm) noexcept { *this = *this - __dm; return *this; } -class year { +class year { private: short __y; public: year() = default; explicit inline constexpr year(int __val) noexcept : __y(static_cast<short>(__val)) {} - inline constexpr year& operator++() noexcept { ++__y; return *this; } - inline constexpr year operator++(int) noexcept { year __tmp = *this; ++(*this); return __tmp; } - inline constexpr year& operator--() noexcept { --__y; return *this; } - inline constexpr year operator--(int) noexcept { year __tmp = *this; --(*this); return __tmp; } + inline constexpr year& operator++() noexcept { ++__y; return *this; } + inline constexpr year operator++(int) noexcept { year __tmp = *this; ++(*this); return __tmp; } + inline constexpr year& operator--() noexcept { --__y; return *this; } + inline constexpr year operator--(int) noexcept { year __tmp = *this; --(*this); return __tmp; } constexpr year& operator+=(const years& __dy) noexcept; constexpr year& operator-=(const years& __dy) noexcept; inline constexpr year operator+() const noexcept { return *this; } - inline constexpr year operator-() const noexcept { return year{-__y}; } + inline constexpr year operator-() const noexcept { return year{-__y}; } inline constexpr bool is_leap() const noexcept { return __y % 4 == 0 && (__y % 100 != 0 || __y % 400 == 0); } explicit inline constexpr operator int() const noexcept { return __y; } @@ -1838,15 +1838,15 @@ inline constexpr year& year::operator-=(const years& __dy) noexcept inline constexpr bool year::ok() const noexcept { return static_cast<int>(min()) <= __y && __y <= static_cast<int>(max()); } -class weekday_indexed; -class weekday_last; +class weekday_indexed; +class weekday_last; -class weekday { +class weekday { private: unsigned char __wd; public: weekday() = default; - inline explicit constexpr weekday(unsigned __val) noexcept : __wd(static_cast<unsigned char>(__val == 7 ? 0 : __val)) {} + inline explicit constexpr weekday(unsigned __val) noexcept : __wd(static_cast<unsigned char>(__val == 7 ? 0 : __val)) {} inline constexpr weekday(const sys_days& __sysd) noexcept : __wd(__weekday_from_days(__sysd.time_since_epoch().count())) {} inline explicit constexpr weekday(const local_days& __locd) noexcept @@ -1858,13 +1858,13 @@ public: inline constexpr weekday operator--(int) noexcept { weekday __tmp = *this; --(*this); return __tmp; } constexpr weekday& operator+=(const days& __dd) noexcept; constexpr weekday& operator-=(const days& __dd) noexcept; - inline constexpr unsigned c_encoding() const noexcept { return __wd; } - inline constexpr unsigned iso_encoding() const noexcept { return __wd == 0u ? 7 : __wd; } + inline constexpr unsigned c_encoding() const noexcept { return __wd; } + inline constexpr unsigned iso_encoding() const noexcept { return __wd == 0u ? 7 : __wd; } inline constexpr bool ok() const noexcept { return __wd <= 6; } constexpr weekday_indexed operator[](unsigned __index) const noexcept; constexpr weekday_last operator[](last_spec) const noexcept; - // TODO: Make private? + // TODO: Make private? static constexpr unsigned char __weekday_from_days(int __days) noexcept; }; @@ -1880,7 +1880,7 @@ unsigned char weekday::__weekday_from_days(int __days) noexcept inline constexpr bool operator==(const weekday& __lhs, const weekday& __rhs) noexcept -{ return __lhs.c_encoding() == __rhs.c_encoding(); } +{ return __lhs.c_encoding() == __rhs.c_encoding(); } inline constexpr bool operator!=(const weekday& __lhs, const weekday& __rhs) noexcept @@ -1888,7 +1888,7 @@ bool operator!=(const weekday& __lhs, const weekday& __rhs) noexcept inline constexpr bool operator< (const weekday& __lhs, const weekday& __rhs) noexcept -{ return __lhs.c_encoding() < __rhs.c_encoding(); } +{ return __lhs.c_encoding() < __rhs.c_encoding(); } inline constexpr bool operator> (const weekday& __lhs, const weekday& __rhs) noexcept @@ -1904,7 +1904,7 @@ bool operator>=(const weekday& __lhs, const weekday& __rhs) noexcept constexpr weekday operator+(const weekday& __lhs, const days& __rhs) noexcept { - auto const __mu = static_cast<long long>(__lhs.c_encoding()) + __rhs.count(); + auto const __mu = static_cast<long long>(__lhs.c_encoding()) + __rhs.count(); auto const __yr = (__mu >= 0 ? __mu : __mu - 6) / 7; return weekday{static_cast<unsigned>(__mu - __yr * 7)}; } @@ -1917,7 +1917,7 @@ constexpr weekday operator-(const weekday& __lhs, const days& __rhs) noexcept constexpr days operator-(const weekday& __lhs, const weekday& __rhs) noexcept { - const int __wdu = __lhs.c_encoding() - __rhs.c_encoding(); + const int __wdu = __lhs.c_encoding() - __rhs.c_encoding(); const int __wk = (__wdu >= 0 ? __wdu : __wdu-6) / 7; return days{__wdu - __wk * 7}; } @@ -1929,15 +1929,15 @@ inline constexpr weekday& weekday::operator-=(const days& __dd) noexcept { *this = *this - __dd; return *this; } -class weekday_indexed { +class weekday_indexed { private: - chrono::weekday __wd; + chrono::weekday __wd; unsigned char __idx; public: weekday_indexed() = default; - inline constexpr weekday_indexed(const chrono::weekday& __wdval, unsigned __idxval) noexcept + inline constexpr weekday_indexed(const chrono::weekday& __wdval, unsigned __idxval) noexcept : __wd{__wdval}, __idx(__idxval) {} - inline constexpr chrono::weekday weekday() const noexcept { return __wd; } + inline constexpr chrono::weekday weekday() const noexcept { return __wd; } inline constexpr unsigned index() const noexcept { return __idx; } inline constexpr bool ok() const noexcept { return __wd.ok() && __idx >= 1 && __idx <= 5; } }; @@ -1951,13 +1951,13 @@ bool operator!=(const weekday_indexed& __lhs, const weekday_indexed& __rhs) noex { return !(__lhs == __rhs); } -class weekday_last { +class weekday_last { private: - chrono::weekday __wd; + chrono::weekday __wd; public: - explicit constexpr weekday_last(const chrono::weekday& __val) noexcept + explicit constexpr weekday_last(const chrono::weekday& __val) noexcept : __wd{__val} {} - constexpr chrono::weekday weekday() const noexcept { return __wd; } + constexpr chrono::weekday weekday() const noexcept { return __wd; } constexpr bool ok() const noexcept { return __wd.ok(); } }; @@ -1999,7 +1999,7 @@ inline constexpr month November{11}; inline constexpr month December{12}; -class month_day { +class month_day { private: chrono::month __m; chrono::day __d; @@ -2074,7 +2074,7 @@ bool operator>=(const month_day& __lhs, const month_day& __rhs) noexcept -class month_day_last { +class month_day_last { private: chrono::month __m; public: @@ -2125,7 +2125,7 @@ month_day_last operator/(last_spec, int __rhs) noexcept { return month_day_last{month(__rhs)}; } -class month_weekday { +class month_weekday { private: chrono::month __m; chrono::weekday_indexed __wdi; @@ -2163,7 +2163,7 @@ month_weekday operator/(const weekday_indexed& __lhs, int __rhs) noexcept { return month_weekday{month(__rhs), __lhs}; } -class month_weekday_last { +class month_weekday_last { chrono::month __m; chrono::weekday_last __wdl; public: @@ -2200,7 +2200,7 @@ month_weekday_last operator/(const weekday_last& __lhs, int __rhs) noexcept { return month_weekday_last{month(__rhs), __lhs}; } -class year_month { +class year_month { chrono::year __y; chrono::month __m; public: @@ -2274,7 +2274,7 @@ constexpr year_month operator-(const year_month& __lhs, const years& __rhs) noex class year_month_day_last; -class year_month_day { +class year_month_day { private: chrono::year __y; chrono::month __m; @@ -2313,8 +2313,8 @@ inline constexpr year_month_day year_month_day::__from_days(days __d) noexcept { - static_assert(numeric_limits<unsigned>::digits >= 18, ""); - static_assert(numeric_limits<int>::digits >= 20 , ""); + static_assert(numeric_limits<unsigned>::digits >= 18, ""); + static_assert(numeric_limits<int>::digits >= 20 , ""); const int __z = __d.count() + 719468; const int __era = (__z >= 0 ? __z : __z - 146096) / 146097; const unsigned __doe = static_cast<unsigned>(__z - __era * 146097); // [0, 146096] @@ -2330,8 +2330,8 @@ year_month_day::__from_days(days __d) noexcept // https://howardhinnant.github.io/date_algorithms.html#days_from_civil inline constexpr days year_month_day::__to_days() const noexcept { - static_assert(numeric_limits<unsigned>::digits >= 18, ""); - static_assert(numeric_limits<int>::digits >= 20 , ""); + static_assert(numeric_limits<unsigned>::digits >= 18, ""); + static_assert(numeric_limits<int>::digits >= 20 , ""); const int __yr = static_cast<int>(__y) - (__m <= February); const unsigned __mth = static_cast<unsigned>(__m); @@ -2428,7 +2428,7 @@ inline constexpr year_month_day& year_month_day::operator-=(const months& __dm) inline constexpr year_month_day& year_month_day::operator+=(const years& __dy) noexcept { *this = *this + __dy; return *this; } inline constexpr year_month_day& year_month_day::operator-=(const years& __dy) noexcept { *this = *this - __dy; return *this; } -class year_month_day_last { +class year_month_day_last { private: chrono::year __y; chrono::month_day_last __mdl; @@ -2460,7 +2460,7 @@ chrono::day year_month_day_last::day() const noexcept chrono::day(31), chrono::day(31), chrono::day(30), chrono::day(31), chrono::day(30), chrono::day(31) }; - return (month() != February || !__y.is_leap()) && month().ok() ? + return (month() != February || !__y.is_leap()) && month().ok() ? __d[static_cast<unsigned>(month()) - 1] : chrono::day{29}; } @@ -2546,7 +2546,7 @@ inline constexpr bool year_month_day::ok() const noexcept return chrono::day{1} <= __d && __d <= (__y / __m / last).day(); } -class year_month_weekday { +class year_month_weekday { chrono::year __y; chrono::month __m; chrono::weekday_indexed __wdi; @@ -2575,13 +2575,13 @@ public: inline constexpr bool ok() const noexcept { if (!__y.ok() || !__m.ok() || !__wdi.ok()) return false; - if (__wdi.index() <= 4) return true; - auto __nth_weekday_day = - __wdi.weekday() - - chrono::weekday{static_cast<sys_days>(__y / __m / 1)} + - days{(__wdi.index() - 1) * 7 + 1}; - return static_cast<unsigned>(__nth_weekday_day.count()) <= - static_cast<unsigned>((__y / __m / last).day()); + if (__wdi.index() <= 4) return true; + auto __nth_weekday_day = + __wdi.weekday() - + chrono::weekday{static_cast<sys_days>(__y / __m / 1)} + + days{(__wdi.index() - 1) * 7 + 1}; + return static_cast<unsigned>(__nth_weekday_day.count()) <= + static_cast<unsigned>((__y / __m / last).day()); } static constexpr year_month_weekday __from_days(days __d) noexcept; @@ -2665,7 +2665,7 @@ inline constexpr year_month_weekday& year_month_weekday::operator-=(const months inline constexpr year_month_weekday& year_month_weekday::operator+=(const years& __dy) noexcept { *this = *this + __dy; return *this; } inline constexpr year_month_weekday& year_month_weekday::operator-=(const years& __dy) noexcept { *this = *this - __dy; return *this; } -class year_month_weekday_last { +class year_month_weekday_last { private: chrono::year __y; chrono::month __m; @@ -2758,160 +2758,160 @@ inline constexpr year_month_weekday_last& year_month_weekday_last::operator-=(co inline constexpr year_month_weekday_last& year_month_weekday_last::operator+=(const years& __dy) noexcept { *this = *this + __dy; return *this; } inline constexpr year_month_weekday_last& year_month_weekday_last::operator-=(const years& __dy) noexcept { *this = *this - __dy; return *this; } - -template <class _Duration> -class hh_mm_ss -{ -private: - static_assert(__is_duration<_Duration>::value, "template parameter of hh_mm_ss must be a std::chrono::duration"); - using __CommonType = common_type_t<_Duration, chrono::seconds>; - - static constexpr uint64_t __pow10(unsigned __exp) - { - uint64_t __ret = 1; - for (unsigned __i = 0; __i < __exp; ++__i) - __ret *= 10U; - return __ret; - } - - static constexpr unsigned __width(uint64_t __n, uint64_t __d = 10, unsigned __w = 0) - { - if (__n >= 2 && __d != 0 && __w < 19) - return 1 + __width(__n, __d % __n * 10, __w+1); - return 0; - } - -public: - static unsigned constexpr fractional_width = __width(__CommonType::period::den) < 19 ? - __width(__CommonType::period::den) : 6u; - using precision = duration<typename __CommonType::rep, ratio<1, __pow10(fractional_width)>>; - - constexpr hh_mm_ss() noexcept : hh_mm_ss{_Duration::zero()} {} - - constexpr explicit hh_mm_ss(_Duration __d) noexcept : - __is_neg(__d < _Duration(0)), - __h(duration_cast<chrono::hours> (abs(__d))), - __m(duration_cast<chrono::minutes>(abs(__d) - hours())), - __s(duration_cast<chrono::seconds>(abs(__d) - hours() - minutes())), - __f(duration_cast<precision> (abs(__d) - hours() - minutes() - seconds())) - {} - - constexpr bool is_negative() const noexcept { return __is_neg; } - constexpr chrono::hours hours() const noexcept { return __h; } - constexpr chrono::minutes minutes() const noexcept { return __m; } - constexpr chrono::seconds seconds() const noexcept { return __s; } - constexpr precision subseconds() const noexcept { return __f; } - - constexpr precision to_duration() const noexcept - { - auto __dur = __h + __m + __s + __f; - return __is_neg ? -__dur : __dur; - } - - constexpr explicit operator precision() const noexcept { return to_duration(); } - -private: - bool __is_neg; - chrono::hours __h; - chrono::minutes __m; - chrono::seconds __s; - precision __f; -}; - -constexpr bool is_am(const hours& __h) noexcept { return __h >= hours( 0) && __h < hours(12); } -constexpr bool is_pm(const hours& __h) noexcept { return __h >= hours(12) && __h < hours(24); } - -constexpr hours make12(const hours& __h) noexcept -{ - if (__h == hours( 0)) return hours(12); - else if (__h <= hours(12)) return __h; - else return __h - hours(12); -} - -constexpr hours make24(const hours& __h, bool __is_pm) noexcept -{ - if (__is_pm) - return __h == hours(12) ? __h : __h + hours(12); - else - return __h == hours(12) ? hours(0) : __h; -} - + +template <class _Duration> +class hh_mm_ss +{ +private: + static_assert(__is_duration<_Duration>::value, "template parameter of hh_mm_ss must be a std::chrono::duration"); + using __CommonType = common_type_t<_Duration, chrono::seconds>; + + static constexpr uint64_t __pow10(unsigned __exp) + { + uint64_t __ret = 1; + for (unsigned __i = 0; __i < __exp; ++__i) + __ret *= 10U; + return __ret; + } + + static constexpr unsigned __width(uint64_t __n, uint64_t __d = 10, unsigned __w = 0) + { + if (__n >= 2 && __d != 0 && __w < 19) + return 1 + __width(__n, __d % __n * 10, __w+1); + return 0; + } + +public: + static unsigned constexpr fractional_width = __width(__CommonType::period::den) < 19 ? + __width(__CommonType::period::den) : 6u; + using precision = duration<typename __CommonType::rep, ratio<1, __pow10(fractional_width)>>; + + constexpr hh_mm_ss() noexcept : hh_mm_ss{_Duration::zero()} {} + + constexpr explicit hh_mm_ss(_Duration __d) noexcept : + __is_neg(__d < _Duration(0)), + __h(duration_cast<chrono::hours> (abs(__d))), + __m(duration_cast<chrono::minutes>(abs(__d) - hours())), + __s(duration_cast<chrono::seconds>(abs(__d) - hours() - minutes())), + __f(duration_cast<precision> (abs(__d) - hours() - minutes() - seconds())) + {} + + constexpr bool is_negative() const noexcept { return __is_neg; } + constexpr chrono::hours hours() const noexcept { return __h; } + constexpr chrono::minutes minutes() const noexcept { return __m; } + constexpr chrono::seconds seconds() const noexcept { return __s; } + constexpr precision subseconds() const noexcept { return __f; } + + constexpr precision to_duration() const noexcept + { + auto __dur = __h + __m + __s + __f; + return __is_neg ? -__dur : __dur; + } + + constexpr explicit operator precision() const noexcept { return to_duration(); } + +private: + bool __is_neg; + chrono::hours __h; + chrono::minutes __m; + chrono::seconds __s; + precision __f; +}; + +constexpr bool is_am(const hours& __h) noexcept { return __h >= hours( 0) && __h < hours(12); } +constexpr bool is_pm(const hours& __h) noexcept { return __h >= hours(12) && __h < hours(24); } + +constexpr hours make12(const hours& __h) noexcept +{ + if (__h == hours( 0)) return hours(12); + else if (__h <= hours(12)) return __h; + else return __h - hours(12); +} + +constexpr hours make24(const hours& __h, bool __is_pm) noexcept +{ + if (__is_pm) + return __h == hours(12) ? __h : __h + hours(12); + else + return __h == hours(12) ? hours(0) : __h; +} + #endif // _LIBCPP_STD_VER > 17 -} // chrono - -#if _LIBCPP_STD_VER > 11 -// Suffixes for duration literals [time.duration.literals] -inline namespace literals -{ - inline namespace chrono_literals - { - +} // chrono + +#if _LIBCPP_STD_VER > 11 +// Suffixes for duration literals [time.duration.literals] +inline namespace literals +{ + inline namespace chrono_literals + { + constexpr chrono::hours operator""h(unsigned long long __h) - { - return chrono::hours(static_cast<chrono::hours::rep>(__h)); - } - + { + return chrono::hours(static_cast<chrono::hours::rep>(__h)); + } + constexpr chrono::duration<long double, ratio<3600,1>> operator""h(long double __h) - { - return chrono::duration<long double, ratio<3600,1>>(__h); - } - - + { + return chrono::duration<long double, ratio<3600,1>>(__h); + } + + constexpr chrono::minutes operator""min(unsigned long long __m) - { - return chrono::minutes(static_cast<chrono::minutes::rep>(__m)); - } - + { + return chrono::minutes(static_cast<chrono::minutes::rep>(__m)); + } + constexpr chrono::duration<long double, ratio<60,1>> operator""min(long double __m) - { - return chrono::duration<long double, ratio<60,1>> (__m); - } - - + { + return chrono::duration<long double, ratio<60,1>> (__m); + } + + constexpr chrono::seconds operator""s(unsigned long long __s) - { - return chrono::seconds(static_cast<chrono::seconds::rep>(__s)); - } - + { + return chrono::seconds(static_cast<chrono::seconds::rep>(__s)); + } + constexpr chrono::duration<long double> operator""s(long double __s) - { - return chrono::duration<long double> (__s); - } - - + { + return chrono::duration<long double> (__s); + } + + constexpr chrono::milliseconds operator""ms(unsigned long long __ms) - { - return chrono::milliseconds(static_cast<chrono::milliseconds::rep>(__ms)); - } - + { + return chrono::milliseconds(static_cast<chrono::milliseconds::rep>(__ms)); + } + constexpr chrono::duration<long double, milli> operator""ms(long double __ms) - { - return chrono::duration<long double, milli>(__ms); - } - - + { + return chrono::duration<long double, milli>(__ms); + } + + constexpr chrono::microseconds operator""us(unsigned long long __us) - { - return chrono::microseconds(static_cast<chrono::microseconds::rep>(__us)); - } - + { + return chrono::microseconds(static_cast<chrono::microseconds::rep>(__us)); + } + constexpr chrono::duration<long double, micro> operator""us(long double __us) - { - return chrono::duration<long double, micro> (__us); - } - - + { + return chrono::duration<long double, micro> (__us); + } + + constexpr chrono::nanoseconds operator""ns(unsigned long long __ns) - { - return chrono::nanoseconds(static_cast<chrono::nanoseconds::rep>(__ns)); - } - + { + return chrono::nanoseconds(static_cast<chrono::nanoseconds::rep>(__ns)); + } + constexpr chrono::duration<long double, nano> operator""ns(long double __ns) - { - return chrono::duration<long double, nano> (__ns); - } - -#if _LIBCPP_STD_VER > 17 + { + return chrono::duration<long double, nano> (__ns); + } + +#if _LIBCPP_STD_VER > 17 constexpr chrono::day operator ""d(unsigned long long __d) noexcept { return chrono::day(static_cast<unsigned>(__d)); @@ -2922,21 +2922,21 @@ inline namespace literals return chrono::year(static_cast<int>(__y)); } #endif -}} - -namespace chrono { // hoist the literals into namespace std::chrono - using namespace literals::chrono_literals; -} - -#endif - -_LIBCPP_END_NAMESPACE_STD - -#ifdef _LIBCPP_COMPILER_MSVC -#pragma warning ( pop ) -#endif - - +}} + +namespace chrono { // hoist the literals into namespace std::chrono + using namespace literals::chrono_literals; +} + +#endif + +_LIBCPP_END_NAMESPACE_STD + +#ifdef _LIBCPP_COMPILER_MSVC +#pragma warning ( pop ) +#endif + + #ifndef _LIBCPP_CXX03_LANG _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM struct _FilesystemClock { @@ -2951,10 +2951,10 @@ struct _FilesystemClock { typedef chrono::duration<rep, period> duration; typedef chrono::time_point<_FilesystemClock> time_point; - _LIBCPP_EXPORTED_FROM_ABI + _LIBCPP_EXPORTED_FROM_ABI static _LIBCPP_CONSTEXPR_AFTER_CXX11 const bool is_steady = false; - _LIBCPP_AVAILABILITY_FILESYSTEM _LIBCPP_FUNC_VIS static time_point now() noexcept; + _LIBCPP_AVAILABILITY_FILESYSTEM _LIBCPP_FUNC_VIS static time_point now() noexcept; _LIBCPP_INLINE_VISIBILITY static time_t to_time_t(const time_point& __t) noexcept { @@ -2972,6 +2972,6 @@ struct _FilesystemClock { _LIBCPP_END_NAMESPACE_FILESYSTEM #endif // !_LIBCPP_CXX03_LANG -_LIBCPP_POP_MACROS - -#endif // _LIBCPP_CHRONO +_LIBCPP_POP_MACROS + +#endif // _LIBCPP_CHRONO |