[libcxx-commits] [libcxx] 5726e55 - [libc++] Modularize <chrono>
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Jan 14 06:56:05 PST 2022
Author: Louis Dionne
Date: 2022-01-14T09:55:29-05:00
New Revision: 5726e55981044b3b2c5bc98272e9ccd0bf58dbec
URL: https://github.com/llvm/llvm-project/commit/5726e55981044b3b2c5bc98272e9ccd0bf58dbec
DIFF: https://github.com/llvm/llvm-project/commit/5726e55981044b3b2c5bc98272e9ccd0bf58dbec.diff
LOG: [libc++] Modularize <chrono>
I didn't split the calendar bits more than this because there was little
benefit to doing it, and I know our calendar support is incomplete.
Whoever picks up the missing calendar bits can organize these headers
at their leisure.
Differential Revision: https://reviews.llvm.org/D116965
Added:
libcxx/include/__chrono/calendar.h
libcxx/include/__chrono/duration.h
libcxx/include/__chrono/file_clock.h
libcxx/include/__chrono/high_resolution_clock.h
libcxx/include/__chrono/steady_clock.h
libcxx/include/__chrono/system_clock.h
libcxx/include/__chrono/time_point.h
libcxx/test/libcxx/diagnostics/detail.headers/chrono/calendar.module.verify.cpp
libcxx/test/libcxx/diagnostics/detail.headers/chrono/duration.module.verify.cpp
libcxx/test/libcxx/diagnostics/detail.headers/chrono/file_clock.module.verify.cpp
libcxx/test/libcxx/diagnostics/detail.headers/chrono/high_resolution_clock.module.verify.cpp
libcxx/test/libcxx/diagnostics/detail.headers/chrono/steady_clock.module.verify.cpp
libcxx/test/libcxx/diagnostics/detail.headers/chrono/system_clock.module.verify.cpp
libcxx/test/libcxx/diagnostics/detail.headers/chrono/time_point.module.verify.cpp
Modified:
libcxx/include/CMakeLists.txt
libcxx/include/__mutex_base
libcxx/include/__thread/poll_with_backoff.h
libcxx/include/chrono
libcxx/include/module.modulemap
libcxx/include/streambuf
libcxx/src/filesystem/filesystem_common.h
libcxx/test/std/input.output/filesystems/fs.filesystem.synopsis/file_time_type_resolution.compile.pass.cpp
libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
libcxx/test/std/utilities/time/days.pass.cpp
libcxx/test/std/utilities/time/hours.pass.cpp
libcxx/test/std/utilities/time/microseconds.pass.cpp
libcxx/test/std/utilities/time/milliseconds.pass.cpp
libcxx/test/std/utilities/time/minutes.pass.cpp
libcxx/test/std/utilities/time/months.pass.cpp
libcxx/test/std/utilities/time/nanoseconds.pass.cpp
libcxx/test/std/utilities/time/seconds.pass.cpp
libcxx/test/std/utilities/time/time.clock/time.clock.file/consistency.pass.cpp
libcxx/test/std/utilities/time/time.clock/time.clock.file/rep_signed.pass.cpp
libcxx/test/std/utilities/time/time.clock/time.clock.hires/consistency.pass.cpp
libcxx/test/std/utilities/time/time.clock/time.clock.steady/consistency.pass.cpp
libcxx/test/std/utilities/time/time.clock/time.clock.system/consistency.pass.cpp
libcxx/test/std/utilities/time/time.duration/default_ratio.pass.cpp
libcxx/test/std/utilities/time/time.duration/time.duration.alg/abs.pass.cpp
libcxx/test/std/utilities/time/time.duration/time.duration.arithmetic/op_+.pass.cpp
libcxx/test/std/utilities/time/time.duration/time.duration.arithmetic/op_-.pass.cpp
libcxx/test/std/utilities/time/time.duration/time.duration.cast/duration_cast.pass.cpp
libcxx/test/std/utilities/time/time.duration/time.duration.comparisons/op_equal.pass.cpp
libcxx/test/std/utilities/time/time.duration/time.duration.comparisons/op_less.pass.cpp
libcxx/test/std/utilities/time/time.duration/time.duration.cons/convert_inexact.pass.cpp
libcxx/test/std/utilities/time/time.duration/time.duration.cons/convert_int_to_float.pass.cpp
libcxx/test/std/utilities/time/time.duration/time.duration.cons/convert_overflow.pass.cpp
libcxx/test/std/utilities/time/time.duration/time.duration.cons/rep.pass.cpp
libcxx/test/std/utilities/time/time.duration/time.duration.nonmember/op_+.pass.cpp
libcxx/test/std/utilities/time/time.duration/time.duration.nonmember/op_-.pass.cpp
libcxx/test/std/utilities/time/time.duration/time.duration.nonmember/op_divide_duration.pass.cpp
libcxx/test/std/utilities/time/time.duration/time.duration.nonmember/op_mod_duration.pass.cpp
libcxx/test/std/utilities/time/time.duration/types.pass.cpp
libcxx/test/std/utilities/time/time.hms/hhmmss.fail.cpp
libcxx/test/std/utilities/time/time.hms/time.12/is_am.pass.cpp
libcxx/test/std/utilities/time/time.hms/time.12/is_pm.pass.cpp
libcxx/test/std/utilities/time/time.hms/time.12/make12.pass.cpp
libcxx/test/std/utilities/time/time.hms/time.12/make24.pass.cpp
libcxx/test/std/utilities/time/time.hms/time.hms.members/hours.pass.cpp
libcxx/test/std/utilities/time/time.hms/time.hms.members/is_negative.pass.cpp
libcxx/test/std/utilities/time/time.hms/time.hms.members/minutes.pass.cpp
libcxx/test/std/utilities/time/time.hms/time.hms.members/precision.pass.cpp
libcxx/test/std/utilities/time/time.hms/time.hms.members/seconds.pass.cpp
libcxx/test/std/utilities/time/time.hms/time.hms.members/subseconds.pass.cpp
libcxx/test/std/utilities/time/time.hms/time.hms.members/to_duration.pass.cpp
libcxx/test/std/utilities/time/time.hms/time.hms.members/width.pass.cpp
libcxx/test/std/utilities/time/time.point/time.point.cast/time_point_cast.pass.cpp
libcxx/test/std/utilities/time/time.point/time.point.cons/default.pass.cpp
libcxx/test/std/utilities/time/time.point/time.point.nonmember/op_-duration.pass.cpp
libcxx/test/std/utilities/time/time.traits/time.traits.specializations/duration.pass.cpp
libcxx/test/std/utilities/time/time.traits/time.traits.specializations/time_point.pass.cpp
libcxx/test/std/utilities/time/weeks.pass.cpp
libcxx/test/std/utilities/time/years.pass.cpp
libcxxabi/src/cxa_guard_impl.h
Removed:
################################################################################
diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt
index cf59ebe43c917..39f23ee856b0e 100644
--- a/libcxx/include/CMakeLists.txt
+++ b/libcxx/include/CMakeLists.txt
@@ -104,6 +104,13 @@ set(files
__charconv/chars_format.h
__charconv/from_chars_result.h
__charconv/to_chars_result.h
+ __chrono/calendar.h
+ __chrono/duration.h
+ __chrono/file_clock.h
+ __chrono/high_resolution_clock.h
+ __chrono/steady_clock.h
+ __chrono/system_clock.h
+ __chrono/time_point.h
__compare/common_comparison_category.h
__compare/compare_three_way.h
__compare/compare_three_way_result.h
diff --git a/libcxx/include/__chrono/calendar.h b/libcxx/include/__chrono/calendar.h
new file mode 100644
index 0000000000000..0854ca60d3dfb
--- /dev/null
+++ b/libcxx/include/__chrono/calendar.h
@@ -0,0 +1,1277 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// 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_CALENDAR_H
+#define _LIBCPP___CHRONO_CALENDAR_H
+
+#include <__chrono/duration.h>
+#include <__chrono/system_clock.h>
+#include <__chrono/time_point.h>
+#include <__config>
+#include <limits>
+#include <ratio>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+#if _LIBCPP_STD_VER > 17
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace chrono
+{
+
+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>;
+
+struct last_spec { explicit last_spec() = default; };
+
+class day {
+private:
+ unsigned char __d;
+public:
+ day() = default;
+ explicit inline constexpr day(unsigned __val) noexcept : __d(static_cast<unsigned char>(__val)) {}
+ inline constexpr day& operator++() noexcept { ++__d; return *this; }
+ inline constexpr day operator++(int) noexcept { day __tmp = *this; ++(*this); return __tmp; }
+ inline constexpr day& operator--() noexcept { --__d; return *this; }
+ inline constexpr day operator--(int) noexcept { day __tmp = *this; --(*this); return __tmp; }
+ constexpr day& operator+=(const days& __dd) noexcept;
+ constexpr day& operator-=(const days& __dd) noexcept;
+ explicit inline constexpr operator unsigned() const noexcept { return __d; }
+ inline constexpr bool ok() const noexcept { return __d >= 1 && __d <= 31; }
+ };
+
+
+inline constexpr
+bool operator==(const day& __lhs, const day& __rhs) noexcept
+{ return static_cast<unsigned>(__lhs) == static_cast<unsigned>(__rhs); }
+
+inline constexpr
+bool operator!=(const day& __lhs, const day& __rhs) noexcept
+{ return !(__lhs == __rhs); }
+
+inline constexpr
+bool operator< (const day& __lhs, const day& __rhs) noexcept
+{ return static_cast<unsigned>(__lhs) < static_cast<unsigned>(__rhs); }
+
+inline constexpr
+bool operator> (const day& __lhs, const day& __rhs) noexcept
+{ return __rhs < __lhs; }
+
+inline constexpr
+bool operator<=(const day& __lhs, const day& __rhs) noexcept
+{ return !(__rhs < __lhs);}
+
+inline constexpr
+bool operator>=(const day& __lhs, const day& __rhs) noexcept
+{ return !(__lhs < __rhs); }
+
+inline constexpr
+day operator+ (const day& __lhs, const days& __rhs) noexcept
+{ return day(static_cast<unsigned>(__lhs) + __rhs.count()); }
+
+inline constexpr
+day operator+ (const days& __lhs, const day& __rhs) noexcept
+{ return __rhs + __lhs; }
+
+inline constexpr
+day operator- (const day& __lhs, const days& __rhs) noexcept
+{ return __lhs + -__rhs; }
+
+inline constexpr
+days operator-(const day& __lhs, const day& __rhs) noexcept
+{ return days(static_cast<int>(static_cast<unsigned>(__lhs)) -
+ static_cast<int>(static_cast<unsigned>(__rhs))); }
+
+inline constexpr day& day::operator+=(const days& __dd) noexcept
+{ *this = *this + __dd; return *this; }
+
+inline constexpr day& day::operator-=(const days& __dd) noexcept
+{ *this = *this - __dd; return *this; }
+
+
+class month {
+private:
+ unsigned char __m;
+public:
+ month() = default;
+ explicit inline constexpr month(unsigned __val) noexcept : __m(static_cast<unsigned char>(__val)) {}
+ inline constexpr month& operator++() noexcept { ++__m; return *this; }
+ inline constexpr month operator++(int) noexcept { month __tmp = *this; ++(*this); return __tmp; }
+ inline constexpr month& operator--() noexcept { --__m; return *this; }
+ inline constexpr month operator--(int) noexcept { month __tmp = *this; --(*this); return __tmp; }
+ constexpr month& operator+=(const months& __m1) noexcept;
+ constexpr month& operator-=(const months& __m1) noexcept;
+ explicit inline constexpr operator unsigned() const noexcept { return __m; }
+ inline constexpr bool ok() const noexcept { return __m >= 1 && __m <= 12; }
+};
+
+
+inline constexpr
+bool operator==(const month& __lhs, const month& __rhs) noexcept
+{ return static_cast<unsigned>(__lhs) == static_cast<unsigned>(__rhs); }
+
+inline constexpr
+bool operator!=(const month& __lhs, const month& __rhs) noexcept
+{ return !(__lhs == __rhs); }
+
+inline constexpr
+bool operator< (const month& __lhs, const month& __rhs) noexcept
+{ return static_cast<unsigned>(__lhs) < static_cast<unsigned>(__rhs); }
+
+inline constexpr
+bool operator> (const month& __lhs, const month& __rhs) noexcept
+{ return __rhs < __lhs; }
+
+inline constexpr
+bool operator<=(const month& __lhs, const month& __rhs) noexcept
+{ return !(__rhs < __lhs); }
+
+inline constexpr
+bool operator>=(const month& __lhs, const month& __rhs) noexcept
+{ return !(__lhs < __rhs); }
+
+inline constexpr
+month operator+ (const month& __lhs, const months& __rhs) noexcept
+{
+ auto const __mu = static_cast<long long>(static_cast<unsigned>(__lhs)) + (__rhs.count() - 1);
+ auto const __yr = (__mu >= 0 ? __mu : __mu - 11) / 12;
+ return month{static_cast<unsigned>(__mu - __yr * 12 + 1)};
+}
+
+inline constexpr
+month operator+ (const months& __lhs, const month& __rhs) noexcept
+{ return __rhs + __lhs; }
+
+inline constexpr
+month operator- (const month& __lhs, const months& __rhs) noexcept
+{ return __lhs + -__rhs; }
+
+inline constexpr
+months operator-(const month& __lhs, const month& __rhs) noexcept
+{
+ auto const __dm = static_cast<unsigned>(__lhs) - static_cast<unsigned>(__rhs);
+ return months(__dm <= 11 ? __dm : __dm + 12);
+}
+
+inline constexpr month& month::operator+=(const months& __dm) noexcept
+{ *this = *this + __dm; return *this; }
+
+inline constexpr month& month::operator-=(const months& __dm) noexcept
+{ *this = *this - __dm; return *this; }
+
+
+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; }
+ 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 bool is_leap() const noexcept { return __y % 4 == 0 && (__y % 100 != 0 || __y % 400 == 0); }
+ explicit inline constexpr operator int() const noexcept { return __y; }
+ constexpr bool ok() const noexcept;
+ static inline constexpr year min() noexcept { return year{-32767}; }
+ static inline constexpr year max() noexcept { return year{ 32767}; }
+};
+
+
+inline constexpr
+bool operator==(const year& __lhs, const year& __rhs) noexcept
+{ return static_cast<int>(__lhs) == static_cast<int>(__rhs); }
+
+inline constexpr
+bool operator!=(const year& __lhs, const year& __rhs) noexcept
+{ return !(__lhs == __rhs); }
+
+inline constexpr
+bool operator< (const year& __lhs, const year& __rhs) noexcept
+{ return static_cast<int>(__lhs) < static_cast<int>(__rhs); }
+
+inline constexpr
+bool operator> (const year& __lhs, const year& __rhs) noexcept
+{ return __rhs < __lhs; }
+
+inline constexpr
+bool operator<=(const year& __lhs, const year& __rhs) noexcept
+{ return !(__rhs < __lhs); }
+
+inline constexpr
+bool operator>=(const year& __lhs, const year& __rhs) noexcept
+{ return !(__lhs < __rhs); }
+
+inline constexpr
+year operator+ (const year& __lhs, const years& __rhs) noexcept
+{ return year(static_cast<int>(__lhs) + __rhs.count()); }
+
+inline constexpr
+year operator+ (const years& __lhs, const year& __rhs) noexcept
+{ return __rhs + __lhs; }
+
+inline constexpr
+year operator- (const year& __lhs, const years& __rhs) noexcept
+{ return __lhs + -__rhs; }
+
+inline constexpr
+years operator-(const year& __lhs, const year& __rhs) noexcept
+{ return years{static_cast<int>(__lhs) - static_cast<int>(__rhs)}; }
+
+
+inline constexpr year& year::operator+=(const years& __dy) noexcept
+{ *this = *this + __dy; return *this; }
+
+inline constexpr year& year::operator-=(const years& __dy) noexcept
+{ *this = *this - __dy; return *this; }
+
+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 {
+private:
+ unsigned char __wd;
+ static constexpr unsigned char __weekday_from_days(int __days) noexcept;
+public:
+ weekday() = default;
+ 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
+ : __wd(__weekday_from_days(__locd.time_since_epoch().count())) {}
+
+ inline constexpr weekday& operator++() noexcept { __wd = (__wd == 6 ? 0 : __wd + 1); return *this; }
+ inline constexpr weekday operator++(int) noexcept { weekday __tmp = *this; ++(*this); return __tmp; }
+ inline constexpr weekday& operator--() noexcept { __wd = (__wd == 0 ? 6 : __wd - 1); return *this; }
+ 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 bool ok() const noexcept { return __wd <= 6; }
+ constexpr weekday_indexed operator[](unsigned __index) const noexcept;
+ constexpr weekday_last operator[](last_spec) const noexcept;
+};
+
+
+// https://howardhinnant.github.io/date_algorithms.html#weekday_from_days
+inline constexpr
+unsigned char weekday::__weekday_from_days(int __days) noexcept
+{
+ return static_cast<unsigned char>(
+ static_cast<unsigned>(__days >= -4 ? (__days+4) % 7 : (__days+5) % 7 + 6)
+ );
+}
+
+inline constexpr
+bool operator==(const weekday& __lhs, const weekday& __rhs) noexcept
+{ return __lhs.c_encoding() == __rhs.c_encoding(); }
+
+inline constexpr
+bool operator!=(const weekday& __lhs, const weekday& __rhs) noexcept
+{ return !(__lhs == __rhs); }
+
+inline constexpr
+bool operator< (const weekday& __lhs, const weekday& __rhs) noexcept
+{ return __lhs.c_encoding() < __rhs.c_encoding(); }
+
+inline constexpr
+bool operator> (const weekday& __lhs, const weekday& __rhs) noexcept
+{ return __rhs < __lhs; }
+
+inline constexpr
+bool operator<=(const weekday& __lhs, const weekday& __rhs) noexcept
+{ return !(__rhs < __lhs);}
+
+inline constexpr
+bool operator>=(const weekday& __lhs, const weekday& __rhs) noexcept
+{ return !(__lhs < __rhs); }
+
+constexpr weekday operator+(const weekday& __lhs, const days& __rhs) noexcept
+{
+ 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)};
+}
+
+constexpr weekday operator+(const days& __lhs, const weekday& __rhs) noexcept
+{ return __rhs + __lhs; }
+
+constexpr weekday operator-(const weekday& __lhs, const days& __rhs) noexcept
+{ return __lhs + -__rhs; }
+
+constexpr days operator-(const weekday& __lhs, const weekday& __rhs) noexcept
+{
+ const int __wdu = __lhs.c_encoding() - __rhs.c_encoding();
+ const int __wk = (__wdu >= 0 ? __wdu : __wdu-6) / 7;
+ return days{__wdu - __wk * 7};
+}
+
+inline constexpr weekday& weekday::operator+=(const days& __dd) noexcept
+{ *this = *this + __dd; return *this; }
+
+inline constexpr weekday& weekday::operator-=(const days& __dd) noexcept
+{ *this = *this - __dd; return *this; }
+
+
+class weekday_indexed {
+private:
+ chrono::weekday __wd;
+ unsigned char __idx;
+public:
+ weekday_indexed() = default;
+ 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 unsigned index() const noexcept { return __idx; }
+ inline constexpr bool ok() const noexcept { return __wd.ok() && __idx >= 1 && __idx <= 5; }
+};
+
+inline constexpr
+bool operator==(const weekday_indexed& __lhs, const weekday_indexed& __rhs) noexcept
+{ return __lhs.weekday() == __rhs.weekday() && __lhs.index() == __rhs.index(); }
+
+inline constexpr
+bool operator!=(const weekday_indexed& __lhs, const weekday_indexed& __rhs) noexcept
+{ return !(__lhs == __rhs); }
+
+
+class weekday_last {
+private:
+ chrono::weekday __wd;
+public:
+ explicit constexpr weekday_last(const chrono::weekday& __val) noexcept
+ : __wd{__val} {}
+ constexpr chrono::weekday weekday() const noexcept { return __wd; }
+ constexpr bool ok() const noexcept { return __wd.ok(); }
+};
+
+inline constexpr
+bool operator==(const weekday_last& __lhs, const weekday_last& __rhs) noexcept
+{ return __lhs.weekday() == __rhs.weekday(); }
+
+inline constexpr
+bool operator!=(const weekday_last& __lhs, const weekday_last& __rhs) noexcept
+{ return !(__lhs == __rhs); }
+
+inline constexpr
+weekday_indexed weekday::operator[](unsigned __index) const noexcept { return weekday_indexed{*this, __index}; }
+
+inline constexpr
+weekday_last weekday::operator[](last_spec) const noexcept { return weekday_last{*this}; }
+
+
+inline constexpr last_spec last{};
+inline constexpr weekday Sunday{0};
+inline constexpr weekday Monday{1};
+inline constexpr weekday Tuesday{2};
+inline constexpr weekday Wednesday{3};
+inline constexpr weekday Thursday{4};
+inline constexpr weekday Friday{5};
+inline constexpr weekday Saturday{6};
+
+inline constexpr month January{1};
+inline constexpr month February{2};
+inline constexpr month March{3};
+inline constexpr month April{4};
+inline constexpr month May{5};
+inline constexpr month June{6};
+inline constexpr month July{7};
+inline constexpr month August{8};
+inline constexpr month September{9};
+inline constexpr month October{10};
+inline constexpr month November{11};
+inline constexpr month December{12};
+
+
+class month_day {
+private:
+ chrono::month __m;
+ chrono::day __d;
+public:
+ month_day() = default;
+ constexpr month_day(const chrono::month& __mval, const chrono::day& __dval) noexcept
+ : __m{__mval}, __d{__dval} {}
+ inline constexpr chrono::month month() const noexcept { return __m; }
+ inline constexpr chrono::day day() const noexcept { return __d; }
+ constexpr bool ok() const noexcept;
+};
+
+inline constexpr
+bool month_day::ok() const noexcept
+{
+ if (!__m.ok()) return false;
+ const unsigned __dval = static_cast<unsigned>(__d);
+ if (__dval < 1 || __dval > 31) return false;
+ if (__dval <= 29) return true;
+// Now we've got either 30 or 31
+ const unsigned __mval = static_cast<unsigned>(__m);
+ if (__mval == 2) return false;
+ if (__mval == 4 || __mval == 6 || __mval == 9 || __mval == 11)
+ return __dval == 30;
+ return true;
+}
+
+inline constexpr
+bool operator==(const month_day& __lhs, const month_day& __rhs) noexcept
+{ return __lhs.month() == __rhs.month() && __lhs.day() == __rhs.day(); }
+
+inline constexpr
+bool operator!=(const month_day& __lhs, const month_day& __rhs) noexcept
+{ return !(__lhs == __rhs); }
+
+inline constexpr
+month_day operator/(const month& __lhs, const day& __rhs) noexcept
+{ return month_day{__lhs, __rhs}; }
+
+constexpr
+month_day operator/(const day& __lhs, const month& __rhs) noexcept
+{ return __rhs / __lhs; }
+
+inline constexpr
+month_day operator/(const month& __lhs, int __rhs) noexcept
+{ return __lhs / day(__rhs); }
+
+constexpr
+month_day operator/(int __lhs, const day& __rhs) noexcept
+{ return month(__lhs) / __rhs; }
+
+constexpr
+month_day operator/(const day& __lhs, int __rhs) noexcept
+{ return month(__rhs) / __lhs; }
+
+
+inline constexpr
+bool operator< (const month_day& __lhs, const month_day& __rhs) noexcept
+{ return __lhs.month() != __rhs.month() ? __lhs.month() < __rhs.month() : __lhs.day() < __rhs.day(); }
+
+inline constexpr
+bool operator> (const month_day& __lhs, const month_day& __rhs) noexcept
+{ return __rhs < __lhs; }
+
+inline constexpr
+bool operator<=(const month_day& __lhs, const month_day& __rhs) noexcept
+{ return !(__rhs < __lhs);}
+
+inline constexpr
+bool operator>=(const month_day& __lhs, const month_day& __rhs) noexcept
+{ return !(__lhs < __rhs); }
+
+
+
+class month_day_last {
+private:
+ chrono::month __m;
+public:
+ explicit constexpr month_day_last(const chrono::month& __val) noexcept
+ : __m{__val} {}
+ inline constexpr chrono::month month() const noexcept { return __m; }
+ inline constexpr bool ok() const noexcept { return __m.ok(); }
+};
+
+inline constexpr
+bool operator==(const month_day_last& __lhs, const month_day_last& __rhs) noexcept
+{ return __lhs.month() == __rhs.month(); }
+
+inline constexpr
+bool operator!=(const month_day_last& __lhs, const month_day_last& __rhs) noexcept
+{ return !(__lhs == __rhs); }
+
+inline constexpr
+bool operator< (const month_day_last& __lhs, const month_day_last& __rhs) noexcept
+{ return __lhs.month() < __rhs.month(); }
+
+inline constexpr
+bool operator> (const month_day_last& __lhs, const month_day_last& __rhs) noexcept
+{ return __rhs < __lhs; }
+
+inline constexpr
+bool operator<=(const month_day_last& __lhs, const month_day_last& __rhs) noexcept
+{ return !(__rhs < __lhs);}
+
+inline constexpr
+bool operator>=(const month_day_last& __lhs, const month_day_last& __rhs) noexcept
+{ return !(__lhs < __rhs); }
+
+inline constexpr
+month_day_last operator/(const month& __lhs, last_spec) noexcept
+{ return month_day_last{__lhs}; }
+
+inline constexpr
+month_day_last operator/(last_spec, const month& __rhs) noexcept
+{ return month_day_last{__rhs}; }
+
+inline constexpr
+month_day_last operator/(int __lhs, last_spec) noexcept
+{ return month_day_last{month(__lhs)}; }
+
+inline constexpr
+month_day_last operator/(last_spec, int __rhs) noexcept
+{ return month_day_last{month(__rhs)}; }
+
+
+class month_weekday {
+private:
+ chrono::month __m;
+ chrono::weekday_indexed __wdi;
+public:
+ month_weekday() = default;
+ constexpr month_weekday(const chrono::month& __mval, const chrono::weekday_indexed& __wdival) noexcept
+ : __m{__mval}, __wdi{__wdival} {}
+ inline constexpr chrono::month month() const noexcept { return __m; }
+ inline constexpr chrono::weekday_indexed weekday_indexed() const noexcept { return __wdi; }
+ inline constexpr bool ok() const noexcept { return __m.ok() && __wdi.ok(); }
+};
+
+inline constexpr
+bool operator==(const month_weekday& __lhs, const month_weekday& __rhs) noexcept
+{ return __lhs.month() == __rhs.month() && __lhs.weekday_indexed() == __rhs.weekday_indexed(); }
+
+inline constexpr
+bool operator!=(const month_weekday& __lhs, const month_weekday& __rhs) noexcept
+{ return !(__lhs == __rhs); }
+
+inline constexpr
+month_weekday operator/(const month& __lhs, const weekday_indexed& __rhs) noexcept
+{ return month_weekday{__lhs, __rhs}; }
+
+inline constexpr
+month_weekday operator/(int __lhs, const weekday_indexed& __rhs) noexcept
+{ return month_weekday{month(__lhs), __rhs}; }
+
+inline constexpr
+month_weekday operator/(const weekday_indexed& __lhs, const month& __rhs) noexcept
+{ return month_weekday{__rhs, __lhs}; }
+
+inline constexpr
+month_weekday operator/(const weekday_indexed& __lhs, int __rhs) noexcept
+{ return month_weekday{month(__rhs), __lhs}; }
+
+
+class month_weekday_last {
+ chrono::month __m;
+ chrono::weekday_last __wdl;
+ public:
+ constexpr month_weekday_last(const chrono::month& __mval, const chrono::weekday_last& __wdlval) noexcept
+ : __m{__mval}, __wdl{__wdlval} {}
+ inline constexpr chrono::month month() const noexcept { return __m; }
+ inline constexpr chrono::weekday_last weekday_last() const noexcept { return __wdl; }
+ inline constexpr bool ok() const noexcept { return __m.ok() && __wdl.ok(); }
+};
+
+inline constexpr
+bool operator==(const month_weekday_last& __lhs, const month_weekday_last& __rhs) noexcept
+{ return __lhs.month() == __rhs.month() && __lhs.weekday_last() == __rhs.weekday_last(); }
+
+inline constexpr
+bool operator!=(const month_weekday_last& __lhs, const month_weekday_last& __rhs) noexcept
+{ return !(__lhs == __rhs); }
+
+
+inline constexpr
+month_weekday_last operator/(const month& __lhs, const weekday_last& __rhs) noexcept
+{ return month_weekday_last{__lhs, __rhs}; }
+
+inline constexpr
+month_weekday_last operator/(int __lhs, const weekday_last& __rhs) noexcept
+{ return month_weekday_last{month(__lhs), __rhs}; }
+
+inline constexpr
+month_weekday_last operator/(const weekday_last& __lhs, const month& __rhs) noexcept
+{ return month_weekday_last{__rhs, __lhs}; }
+
+inline constexpr
+month_weekday_last operator/(const weekday_last& __lhs, int __rhs) noexcept
+{ return month_weekday_last{month(__rhs), __lhs}; }
+
+
+class year_month {
+ chrono::year __y;
+ chrono::month __m;
+public:
+ year_month() = default;
+ constexpr year_month(const chrono::year& __yval, const chrono::month& __mval) noexcept
+ : __y{__yval}, __m{__mval} {}
+ inline constexpr chrono::year year() const noexcept { return __y; }
+ inline constexpr chrono::month month() const noexcept { return __m; }
+ inline constexpr year_month& operator+=(const months& __dm) noexcept { this->__m += __dm; return *this; }
+ inline constexpr year_month& operator-=(const months& __dm) noexcept { this->__m -= __dm; return *this; }
+ inline constexpr year_month& operator+=(const years& __dy) noexcept { this->__y += __dy; return *this; }
+ inline constexpr year_month& operator-=(const years& __dy) noexcept { this->__y -= __dy; return *this; }
+ inline constexpr bool ok() const noexcept { return __y.ok() && __m.ok(); }
+};
+
+inline constexpr
+year_month operator/(const year& __y, const month& __m) noexcept { return year_month{__y, __m}; }
+
+inline constexpr
+year_month operator/(const year& __y, int __m) noexcept { return year_month{__y, month(__m)}; }
+
+inline constexpr
+bool operator==(const year_month& __lhs, const year_month& __rhs) noexcept
+{ return __lhs.year() == __rhs.year() && __lhs.month() == __rhs.month(); }
+
+inline constexpr
+bool operator!=(const year_month& __lhs, const year_month& __rhs) noexcept
+{ return !(__lhs == __rhs); }
+
+inline constexpr
+bool operator< (const year_month& __lhs, const year_month& __rhs) noexcept
+{ return __lhs.year() != __rhs.year() ? __lhs.year() < __rhs.year() : __lhs.month() < __rhs.month(); }
+
+inline constexpr
+bool operator> (const year_month& __lhs, const year_month& __rhs) noexcept
+{ return __rhs < __lhs; }
+
+inline constexpr
+bool operator<=(const year_month& __lhs, const year_month& __rhs) noexcept
+{ return !(__rhs < __lhs);}
+
+inline constexpr
+bool operator>=(const year_month& __lhs, const year_month& __rhs) noexcept
+{ return !(__lhs < __rhs); }
+
+constexpr year_month operator+(const year_month& __lhs, const months& __rhs) noexcept
+{
+ int __dmi = static_cast<int>(static_cast<unsigned>(__lhs.month())) - 1 + __rhs.count();
+ const int __dy = (__dmi >= 0 ? __dmi : __dmi-11) / 12;
+ __dmi = __dmi - __dy * 12 + 1;
+ return (__lhs.year() + years(__dy)) / month(static_cast<unsigned>(__dmi));
+}
+
+constexpr year_month operator+(const months& __lhs, const year_month& __rhs) noexcept
+{ return __rhs + __lhs; }
+
+constexpr year_month operator+(const year_month& __lhs, const years& __rhs) noexcept
+{ return (__lhs.year() + __rhs) / __lhs.month(); }
+
+constexpr year_month operator+(const years& __lhs, const year_month& __rhs) noexcept
+{ return __rhs + __lhs; }
+
+constexpr months operator-(const year_month& __lhs, const year_month& __rhs) noexcept
+{ return (__lhs.year() - __rhs.year()) + months(static_cast<unsigned>(__lhs.month()) - static_cast<unsigned>(__rhs.month())); }
+
+constexpr year_month operator-(const year_month& __lhs, const months& __rhs) noexcept
+{ return __lhs + -__rhs; }
+
+constexpr year_month operator-(const year_month& __lhs, const years& __rhs) noexcept
+{ return __lhs + -__rhs; }
+
+class year_month_day_last;
+
+class year_month_day {
+private:
+ chrono::year __y;
+ chrono::month __m;
+ chrono::day __d;
+public:
+ year_month_day() = default;
+ inline constexpr year_month_day(
+ const chrono::year& __yval, const chrono::month& __mval, const chrono::day& __dval) noexcept
+ : __y{__yval}, __m{__mval}, __d{__dval} {}
+ constexpr year_month_day(const year_month_day_last& __ymdl) noexcept;
+ inline constexpr year_month_day(const sys_days& __sysd) noexcept
+ : year_month_day(__from_days(__sysd.time_since_epoch())) {}
+ inline explicit constexpr year_month_day(const local_days& __locd) noexcept
+ : year_month_day(__from_days(__locd.time_since_epoch())) {}
+
+ constexpr year_month_day& operator+=(const months& __dm) noexcept;
+ constexpr year_month_day& operator-=(const months& __dm) noexcept;
+ constexpr year_month_day& operator+=(const years& __dy) noexcept;
+ constexpr year_month_day& operator-=(const years& __dy) noexcept;
+
+ inline constexpr chrono::year year() const noexcept { return __y; }
+ inline constexpr chrono::month month() const noexcept { return __m; }
+ inline constexpr chrono::day day() const noexcept { return __d; }
+ inline constexpr operator sys_days() const noexcept { return sys_days{__to_days()}; }
+ inline explicit constexpr operator local_days() const noexcept { return local_days{__to_days()}; }
+
+ constexpr bool ok() const noexcept;
+
+ static constexpr year_month_day __from_days(days __d) noexcept;
+ constexpr days __to_days() const noexcept;
+};
+
+
+// https://howardhinnant.github.io/date_algorithms.html#civil_from_days
+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 , "");
+ 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]
+ const unsigned __yoe = (__doe - __doe/1460 + __doe/36524 - __doe/146096) / 365; // [0, 399]
+ const int __yr = static_cast<int>(__yoe) + __era * 400;
+ const unsigned __doy = __doe - (365 * __yoe + __yoe/4 - __yoe/100); // [0, 365]
+ const unsigned __mp = (5 * __doy + 2)/153; // [0, 11]
+ const unsigned __dy = __doy - (153 * __mp + 2)/5 + 1; // [1, 31]
+ const unsigned __mth = __mp + (__mp < 10 ? 3 : -9); // [1, 12]
+ return year_month_day{chrono::year{__yr + (__mth <= 2)}, chrono::month{__mth}, chrono::day{__dy}};
+}
+
+// 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 , "");
+
+ const int __yr = static_cast<int>(__y) - (__m <= February);
+ const unsigned __mth = static_cast<unsigned>(__m);
+ const unsigned __dy = static_cast<unsigned>(__d);
+
+ const int __era = (__yr >= 0 ? __yr : __yr - 399) / 400;
+ const unsigned __yoe = static_cast<unsigned>(__yr - __era * 400); // [0, 399]
+ const unsigned __doy = (153 * (__mth + (__mth > 2 ? -3 : 9)) + 2) / 5 + __dy-1; // [0, 365]
+ const unsigned __doe = __yoe * 365 + __yoe/4 - __yoe/100 + __doy; // [0, 146096]
+ return days{__era * 146097 + static_cast<int>(__doe) - 719468};
+}
+
+inline constexpr
+bool operator==(const year_month_day& __lhs, const year_month_day& __rhs) noexcept
+{ return __lhs.year() == __rhs.year() && __lhs.month() == __rhs.month() && __lhs.day() == __rhs.day(); }
+
+inline constexpr
+bool operator!=(const year_month_day& __lhs, const year_month_day& __rhs) noexcept
+{ return !(__lhs == __rhs); }
+
+inline constexpr
+bool operator< (const year_month_day& __lhs, const year_month_day& __rhs) noexcept
+{
+ if (__lhs.year() < __rhs.year()) return true;
+ if (__lhs.year() > __rhs.year()) return false;
+ if (__lhs.month() < __rhs.month()) return true;
+ if (__lhs.month() > __rhs.month()) return false;
+ return __lhs.day() < __rhs.day();
+}
+
+inline constexpr
+bool operator> (const year_month_day& __lhs, const year_month_day& __rhs) noexcept
+{ return __rhs < __lhs; }
+
+inline constexpr
+bool operator<=(const year_month_day& __lhs, const year_month_day& __rhs) noexcept
+{ return !(__rhs < __lhs);}
+
+inline constexpr
+bool operator>=(const year_month_day& __lhs, const year_month_day& __rhs) noexcept
+{ return !(__lhs < __rhs); }
+
+inline constexpr
+year_month_day operator/(const year_month& __lhs, const day& __rhs) noexcept
+{ return year_month_day{__lhs.year(), __lhs.month(), __rhs}; }
+
+inline constexpr
+year_month_day operator/(const year_month& __lhs, int __rhs) noexcept
+{ return __lhs / day(__rhs); }
+
+inline constexpr
+year_month_day operator/(const year& __lhs, const month_day& __rhs) noexcept
+{ return __lhs / __rhs.month() / __rhs.day(); }
+
+inline constexpr
+year_month_day operator/(int __lhs, const month_day& __rhs) noexcept
+{ return year(__lhs) / __rhs; }
+
+inline constexpr
+year_month_day operator/(const month_day& __lhs, const year& __rhs) noexcept
+{ return __rhs / __lhs; }
+
+inline constexpr
+year_month_day operator/(const month_day& __lhs, int __rhs) noexcept
+{ return year(__rhs) / __lhs; }
+
+
+inline constexpr
+year_month_day operator+(const year_month_day& __lhs, const months& __rhs) noexcept
+{ return (__lhs.year()/__lhs.month() + __rhs)/__lhs.day(); }
+
+inline constexpr
+year_month_day operator+(const months& __lhs, const year_month_day& __rhs) noexcept
+{ return __rhs + __lhs; }
+
+inline constexpr
+year_month_day operator-(const year_month_day& __lhs, const months& __rhs) noexcept
+{ return __lhs + -__rhs; }
+
+inline constexpr
+year_month_day operator+(const year_month_day& __lhs, const years& __rhs) noexcept
+{ return (__lhs.year() + __rhs) / __lhs.month() / __lhs.day(); }
+
+inline constexpr
+year_month_day operator+(const years& __lhs, const year_month_day& __rhs) noexcept
+{ return __rhs + __lhs; }
+
+inline constexpr
+year_month_day operator-(const year_month_day& __lhs, const years& __rhs) noexcept
+{ return __lhs + -__rhs; }
+
+inline constexpr year_month_day& year_month_day::operator+=(const months& __dm) noexcept { *this = *this + __dm; return *this; }
+inline constexpr year_month_day& year_month_day::operator-=(const months& __dm) noexcept { *this = *this - __dm; return *this; }
+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 {
+private:
+ chrono::year __y;
+ chrono::month_day_last __mdl;
+public:
+ constexpr year_month_day_last(const year& __yval, const month_day_last& __mdlval) noexcept
+ : __y{__yval}, __mdl{__mdlval} {}
+
+ constexpr year_month_day_last& operator+=(const months& __m) noexcept;
+ constexpr year_month_day_last& operator-=(const months& __m) noexcept;
+ constexpr year_month_day_last& operator+=(const years& __y) noexcept;
+ constexpr year_month_day_last& operator-=(const years& __y) noexcept;
+
+ inline constexpr chrono::year year() const noexcept { return __y; }
+ inline constexpr chrono::month month() const noexcept { return __mdl.month(); }
+ inline constexpr chrono::month_day_last month_day_last() const noexcept { return __mdl; }
+ constexpr chrono::day day() const noexcept;
+ inline constexpr operator sys_days() const noexcept { return sys_days{year()/month()/day()}; }
+ inline explicit constexpr operator local_days() const noexcept { return local_days{year()/month()/day()}; }
+ inline constexpr bool ok() const noexcept { return __y.ok() && __mdl.ok(); }
+};
+
+inline constexpr
+chrono::day year_month_day_last::day() const noexcept
+{
+ constexpr chrono::day __d[] =
+ {
+ chrono::day(31), chrono::day(28), chrono::day(31),
+ chrono::day(30), chrono::day(31), chrono::day(30),
+ 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() ?
+ __d[static_cast<unsigned>(month()) - 1] : chrono::day{29};
+}
+
+inline constexpr
+bool operator==(const year_month_day_last& __lhs, const year_month_day_last& __rhs) noexcept
+{ return __lhs.year() == __rhs.year() && __lhs.month_day_last() == __rhs.month_day_last(); }
+
+inline constexpr
+bool operator!=(const year_month_day_last& __lhs, const year_month_day_last& __rhs) noexcept
+{ return !(__lhs == __rhs); }
+
+inline constexpr
+bool operator< (const year_month_day_last& __lhs, const year_month_day_last& __rhs) noexcept
+{
+ if (__lhs.year() < __rhs.year()) return true;
+ if (__lhs.year() > __rhs.year()) return false;
+ return __lhs.month_day_last() < __rhs.month_day_last();
+}
+
+inline constexpr
+bool operator> (const year_month_day_last& __lhs, const year_month_day_last& __rhs) noexcept
+{ return __rhs < __lhs; }
+
+inline constexpr
+bool operator<=(const year_month_day_last& __lhs, const year_month_day_last& __rhs) noexcept
+{ return !(__rhs < __lhs);}
+
+inline constexpr
+bool operator>=(const year_month_day_last& __lhs, const year_month_day_last& __rhs) noexcept
+{ return !(__lhs < __rhs); }
+
+inline constexpr year_month_day_last operator/(const year_month& __lhs, last_spec) noexcept
+{ return year_month_day_last{__lhs.year(), month_day_last{__lhs.month()}}; }
+
+inline constexpr year_month_day_last operator/(const year& __lhs, const month_day_last& __rhs) noexcept
+{ return year_month_day_last{__lhs, __rhs}; }
+
+inline constexpr year_month_day_last operator/(int __lhs, const month_day_last& __rhs) noexcept
+{ return year_month_day_last{year{__lhs}, __rhs}; }
+
+inline constexpr year_month_day_last operator/(const month_day_last& __lhs, const year& __rhs) noexcept
+{ return __rhs / __lhs; }
+
+inline constexpr year_month_day_last operator/(const month_day_last& __lhs, int __rhs) noexcept
+{ return year{__rhs} / __lhs; }
+
+
+inline constexpr
+year_month_day_last operator+(const year_month_day_last& __lhs, const months& __rhs) noexcept
+{ return (__lhs.year() / __lhs.month() + __rhs) / last; }
+
+inline constexpr
+year_month_day_last operator+(const months& __lhs, const year_month_day_last& __rhs) noexcept
+{ return __rhs + __lhs; }
+
+inline constexpr
+year_month_day_last operator-(const year_month_day_last& __lhs, const months& __rhs) noexcept
+{ return __lhs + (-__rhs); }
+
+inline constexpr
+year_month_day_last operator+(const year_month_day_last& __lhs, const years& __rhs) noexcept
+{ return year_month_day_last{__lhs.year() + __rhs, __lhs.month_day_last()}; }
+
+inline constexpr
+year_month_day_last operator+(const years& __lhs, const year_month_day_last& __rhs) noexcept
+{ return __rhs + __lhs; }
+
+inline constexpr
+year_month_day_last operator-(const year_month_day_last& __lhs, const years& __rhs) noexcept
+{ return __lhs + (-__rhs); }
+
+inline constexpr year_month_day_last& year_month_day_last::operator+=(const months& __dm) noexcept { *this = *this + __dm; return *this; }
+inline constexpr year_month_day_last& year_month_day_last::operator-=(const months& __dm) noexcept { *this = *this - __dm; return *this; }
+inline constexpr year_month_day_last& year_month_day_last::operator+=(const years& __dy) noexcept { *this = *this + __dy; return *this; }
+inline constexpr year_month_day_last& year_month_day_last::operator-=(const years& __dy) noexcept { *this = *this - __dy; return *this; }
+
+inline constexpr year_month_day::year_month_day(const year_month_day_last& __ymdl) noexcept
+ : __y{__ymdl.year()}, __m{__ymdl.month()}, __d{__ymdl.day()} {}
+
+inline constexpr bool year_month_day::ok() const noexcept
+{
+ if (!__y.ok() || !__m.ok()) return false;
+ return chrono::day{1} <= __d && __d <= (__y / __m / last).day();
+}
+
+class year_month_weekday {
+ chrono::year __y;
+ chrono::month __m;
+ chrono::weekday_indexed __wdi;
+public:
+ year_month_weekday() = default;
+ constexpr year_month_weekday(const chrono::year& __yval, const chrono::month& __mval,
+ const chrono::weekday_indexed& __wdival) noexcept
+ : __y{__yval}, __m{__mval}, __wdi{__wdival} {}
+ constexpr year_month_weekday(const sys_days& __sysd) noexcept
+ : year_month_weekday(__from_days(__sysd.time_since_epoch())) {}
+ inline explicit constexpr year_month_weekday(const local_days& __locd) noexcept
+ : year_month_weekday(__from_days(__locd.time_since_epoch())) {}
+ constexpr year_month_weekday& operator+=(const months& m) noexcept;
+ constexpr year_month_weekday& operator-=(const months& m) noexcept;
+ constexpr year_month_weekday& operator+=(const years& y) noexcept;
+ constexpr year_month_weekday& operator-=(const years& y) noexcept;
+
+ inline constexpr chrono::year year() const noexcept { return __y; }
+ inline constexpr chrono::month month() const noexcept { return __m; }
+ inline constexpr chrono::weekday weekday() const noexcept { return __wdi.weekday(); }
+ inline constexpr unsigned index() const noexcept { return __wdi.index(); }
+ inline constexpr chrono::weekday_indexed weekday_indexed() const noexcept { return __wdi; }
+
+ inline constexpr operator sys_days() const noexcept { return sys_days{__to_days()}; }
+ inline explicit constexpr operator local_days() const noexcept { return local_days{__to_days()}; }
+ 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());
+ }
+
+ static constexpr year_month_weekday __from_days(days __d) noexcept;
+ constexpr days __to_days() const noexcept;
+};
+
+inline constexpr
+year_month_weekday year_month_weekday::__from_days(days __d) noexcept
+{
+ const sys_days __sysd{__d};
+ const chrono::weekday __wd = chrono::weekday(__sysd);
+ const year_month_day __ymd = year_month_day(__sysd);
+ return year_month_weekday{__ymd.year(), __ymd.month(),
+ __wd[(static_cast<unsigned>(__ymd.day())-1)/7+1]};
+}
+
+inline constexpr
+days year_month_weekday::__to_days() const noexcept
+{
+ const sys_days __sysd = sys_days(__y/__m/1);
+ return (__sysd + (__wdi.weekday() - chrono::weekday(__sysd) + days{(__wdi.index()-1)*7}))
+ .time_since_epoch();
+}
+
+inline constexpr
+bool operator==(const year_month_weekday& __lhs, const year_month_weekday& __rhs) noexcept
+{ return __lhs.year() == __rhs.year() && __lhs.month() == __rhs.month() && __lhs.weekday_indexed() == __rhs.weekday_indexed(); }
+
+inline constexpr
+bool operator!=(const year_month_weekday& __lhs, const year_month_weekday& __rhs) noexcept
+{ return !(__lhs == __rhs); }
+
+inline constexpr
+year_month_weekday operator/(const year_month& __lhs, const weekday_indexed& __rhs) noexcept
+{ return year_month_weekday{__lhs.year(), __lhs.month(), __rhs}; }
+
+inline constexpr
+year_month_weekday operator/(const year& __lhs, const month_weekday& __rhs) noexcept
+{ return year_month_weekday{__lhs, __rhs.month(), __rhs.weekday_indexed()}; }
+
+inline constexpr
+year_month_weekday operator/(int __lhs, const month_weekday& __rhs) noexcept
+{ return year(__lhs) / __rhs; }
+
+inline constexpr
+year_month_weekday operator/(const month_weekday& __lhs, const year& __rhs) noexcept
+{ return __rhs / __lhs; }
+
+inline constexpr
+year_month_weekday operator/(const month_weekday& __lhs, int __rhs) noexcept
+{ return year(__rhs) / __lhs; }
+
+
+inline constexpr
+year_month_weekday operator+(const year_month_weekday& __lhs, const months& __rhs) noexcept
+{ return (__lhs.year() / __lhs.month() + __rhs) / __lhs.weekday_indexed(); }
+
+inline constexpr
+year_month_weekday operator+(const months& __lhs, const year_month_weekday& __rhs) noexcept
+{ return __rhs + __lhs; }
+
+inline constexpr
+year_month_weekday operator-(const year_month_weekday& __lhs, const months& __rhs) noexcept
+{ return __lhs + (-__rhs); }
+
+inline constexpr
+year_month_weekday operator+(const year_month_weekday& __lhs, const years& __rhs) noexcept
+{ return year_month_weekday{__lhs.year() + __rhs, __lhs.month(), __lhs.weekday_indexed()}; }
+
+inline constexpr
+year_month_weekday operator+(const years& __lhs, const year_month_weekday& __rhs) noexcept
+{ return __rhs + __lhs; }
+
+inline constexpr
+year_month_weekday operator-(const year_month_weekday& __lhs, const years& __rhs) noexcept
+{ return __lhs + (-__rhs); }
+
+
+inline constexpr year_month_weekday& year_month_weekday::operator+=(const months& __dm) noexcept { *this = *this + __dm; return *this; }
+inline constexpr year_month_weekday& year_month_weekday::operator-=(const months& __dm) noexcept { *this = *this - __dm; return *this; }
+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 {
+private:
+ chrono::year __y;
+ chrono::month __m;
+ chrono::weekday_last __wdl;
+public:
+ constexpr year_month_weekday_last(const chrono::year& __yval, const chrono::month& __mval,
+ const chrono::weekday_last& __wdlval) noexcept
+ : __y{__yval}, __m{__mval}, __wdl{__wdlval} {}
+ constexpr year_month_weekday_last& operator+=(const months& __dm) noexcept;
+ constexpr year_month_weekday_last& operator-=(const months& __dm) noexcept;
+ constexpr year_month_weekday_last& operator+=(const years& __dy) noexcept;
+ constexpr year_month_weekday_last& operator-=(const years& __dy) noexcept;
+
+ inline constexpr chrono::year year() const noexcept { return __y; }
+ inline constexpr chrono::month month() const noexcept { return __m; }
+ inline constexpr chrono::weekday weekday() const noexcept { return __wdl.weekday(); }
+ inline constexpr chrono::weekday_last weekday_last() const noexcept { return __wdl; }
+ inline constexpr operator sys_days() const noexcept { return sys_days{__to_days()}; }
+ inline explicit constexpr operator local_days() const noexcept { return local_days{__to_days()}; }
+ inline constexpr bool ok() const noexcept { return __y.ok() && __m.ok() && __wdl.ok(); }
+
+ constexpr days __to_days() const noexcept;
+
+};
+
+inline constexpr
+days year_month_weekday_last::__to_days() const noexcept
+{
+ const sys_days __last = sys_days{__y/__m/last};
+ return (__last - (chrono::weekday{__last} - __wdl.weekday())).time_since_epoch();
+
+}
+
+inline constexpr
+bool operator==(const year_month_weekday_last& __lhs, const year_month_weekday_last& __rhs) noexcept
+{ return __lhs.year() == __rhs.year() && __lhs.month() == __rhs.month() && __lhs.weekday_last() == __rhs.weekday_last(); }
+
+inline constexpr
+bool operator!=(const year_month_weekday_last& __lhs, const year_month_weekday_last& __rhs) noexcept
+{ return !(__lhs == __rhs); }
+
+
+inline constexpr
+year_month_weekday_last operator/(const year_month& __lhs, const weekday_last& __rhs) noexcept
+{ return year_month_weekday_last{__lhs.year(), __lhs.month(), __rhs}; }
+
+inline constexpr
+year_month_weekday_last operator/(const year& __lhs, const month_weekday_last& __rhs) noexcept
+{ return year_month_weekday_last{__lhs, __rhs.month(), __rhs.weekday_last()}; }
+
+inline constexpr
+year_month_weekday_last operator/(int __lhs, const month_weekday_last& __rhs) noexcept
+{ return year(__lhs) / __rhs; }
+
+inline constexpr
+year_month_weekday_last operator/(const month_weekday_last& __lhs, const year& __rhs) noexcept
+{ return __rhs / __lhs; }
+
+inline constexpr
+year_month_weekday_last operator/(const month_weekday_last& __lhs, int __rhs) noexcept
+{ return year(__rhs) / __lhs; }
+
+
+inline constexpr
+year_month_weekday_last operator+(const year_month_weekday_last& __lhs, const months& __rhs) noexcept
+{ return (__lhs.year() / __lhs.month() + __rhs) / __lhs.weekday_last(); }
+
+inline constexpr
+year_month_weekday_last operator+(const months& __lhs, const year_month_weekday_last& __rhs) noexcept
+{ return __rhs + __lhs; }
+
+inline constexpr
+year_month_weekday_last operator-(const year_month_weekday_last& __lhs, const months& __rhs) noexcept
+{ return __lhs + (-__rhs); }
+
+inline constexpr
+year_month_weekday_last operator+(const year_month_weekday_last& __lhs, const years& __rhs) noexcept
+{ return year_month_weekday_last{__lhs.year() + __rhs, __lhs.month(), __lhs.weekday_last()}; }
+
+inline constexpr
+year_month_weekday_last operator+(const years& __lhs, const year_month_weekday_last& __rhs) noexcept
+{ return __rhs + __lhs; }
+
+inline constexpr
+year_month_weekday_last operator-(const year_month_weekday_last& __lhs, const years& __rhs) noexcept
+{ return __lhs + (-__rhs); }
+
+inline constexpr year_month_weekday_last& year_month_weekday_last::operator+=(const months& __dm) noexcept { *this = *this + __dm; return *this; }
+inline constexpr year_month_weekday_last& year_month_weekday_last::operator-=(const months& __dm) noexcept { *this = *this - __dm; return *this; }
+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;
+}
+
+} // namespace chrono
+
+inline namespace literals
+{
+ inline namespace chrono_literals
+ {
+ constexpr chrono::day operator ""d(unsigned long long __d) noexcept
+ {
+ return chrono::day(static_cast<unsigned>(__d));
+ }
+
+ constexpr chrono::year operator ""y(unsigned long long __y) noexcept
+ {
+ return chrono::year(static_cast<int>(__y));
+ }
+} // namespace chrono_literals
+} // namespace literals
+
+namespace chrono { // hoist the literals into namespace std::chrono
+ using namespace literals::chrono_literals;
+} // namespace chrono
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___CHRONO_CALENDAR_H
diff --git a/libcxx/include/__chrono/duration.h b/libcxx/include/__chrono/duration.h
new file mode 100644
index 0000000000000..24801772ec5d8
--- /dev/null
+++ b/libcxx/include/__chrono/duration.h
@@ -0,0 +1,615 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// 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_DURATION_H
+#define _LIBCPP___CHRONO_DURATION_H
+
+#include <__config>
+#include <limits>
+#include <ratio>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_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 {};
+
+} // namespace 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
+#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
+
+ _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;
+#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()));
+}
+
+} // namespace 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));
+ }
+
+ constexpr chrono::duration<long double, ratio<3600,1>> operator""h(long double __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));
+ }
+
+ constexpr chrono::duration<long double, ratio<60,1>> operator""min(long double __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));
+ }
+
+ constexpr chrono::duration<long double> operator""s(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));
+ }
+
+ constexpr chrono::duration<long double, milli> operator""ms(long double __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));
+ }
+
+ constexpr chrono::duration<long double, micro> operator""us(long double __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));
+ }
+
+ constexpr chrono::duration<long double, nano> operator""ns(long double __ns)
+ {
+ return chrono::duration<long double, nano> (__ns);
+ }
+
+} // namespace chrono_literals
+} // namespace literals
+
+namespace chrono { // hoist the literals into namespace std::chrono
+ using namespace literals::chrono_literals;
+} // namespace chrono
+
+#endif // _LIBCPP_STD_VER > 11
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___CHRONO_DURATION_H
diff --git a/libcxx/include/__chrono/file_clock.h b/libcxx/include/__chrono/file_clock.h
new file mode 100644
index 0000000000000..cd8758f81908c
--- /dev/null
+++ b/libcxx/include/__chrono/file_clock.h
@@ -0,0 +1,85 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// 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_FILE_CLOCK_H
+#define _LIBCPP___CHRONO_FILE_CLOCK_H
+
+#include <__availability>
+#include <__chrono/duration.h>
+#include <__chrono/system_clock.h>
+#include <__chrono/time_point.h>
+#include <__config>
+#include <ratio>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+#ifndef _LIBCPP_CXX03_LANG
+_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
+struct _FilesystemClock;
+_LIBCPP_END_NAMESPACE_FILESYSTEM
+#endif // !_LIBCPP_CXX03_LANG
+
+#if _LIBCPP_STD_VER > 17
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace chrono
+{
+
+// [time.clock.file], type file_clock
+using file_clock = _VSTD_FS::_FilesystemClock;
+
+template<class _Duration>
+using file_time = time_point<file_clock, _Duration>;
+
+} // namespace chrono
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17
+
+#ifndef _LIBCPP_CXX03_LANG
+_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
+struct _FilesystemClock {
+#if !defined(_LIBCPP_HAS_NO_INT128)
+ typedef __int128_t rep;
+ typedef nano period;
+#else
+ typedef long long rep;
+ typedef nano period;
+#endif
+
+ typedef chrono::duration<rep, period> duration;
+ typedef chrono::time_point<_FilesystemClock> time_point;
+
+ _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;
+
+#if _LIBCPP_STD_VER > 17
+ template <class _Duration>
+ _LIBCPP_HIDE_FROM_ABI
+ static chrono::sys_time<_Duration> to_sys(const chrono::file_time<_Duration>& __t) {
+ return chrono::sys_time<_Duration>(__t.time_since_epoch());
+ }
+
+ template <class _Duration>
+ _LIBCPP_HIDE_FROM_ABI
+ static chrono::file_time<_Duration> from_sys(const chrono::sys_time<_Duration>& __t) {
+ return chrono::file_time<_Duration>(__t.time_since_epoch());
+ }
+#endif // _LIBCPP_STD_VER > 17
+};
+_LIBCPP_END_NAMESPACE_FILESYSTEM
+#endif // !_LIBCPP_CXX03_LANG
+
+#endif // _LIBCPP___CHRONO_FILE_CLOCK_H
diff --git a/libcxx/include/__chrono/high_resolution_clock.h b/libcxx/include/__chrono/high_resolution_clock.h
new file mode 100644
index 0000000000000..f5cde4acb9793
--- /dev/null
+++ b/libcxx/include/__chrono/high_resolution_clock.h
@@ -0,0 +1,36 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// 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_HIGH_RESOLUTION_CLOCK_H
+#define _LIBCPP___CHRONO_HIGH_RESOLUTION_CLOCK_H
+
+#include <__chrono/steady_clock.h>
+#include <__chrono/system_clock.h>
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace chrono
+{
+
+#ifndef _LIBCPP_HAS_NO_MONOTONIC_CLOCK
+typedef steady_clock high_resolution_clock;
+#else
+typedef system_clock high_resolution_clock;
+#endif
+
+} // namespace chrono
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___CHRONO_HIGH_RESOLUTION_CLOCK_H
diff --git a/libcxx/include/__chrono/steady_clock.h b/libcxx/include/__chrono/steady_clock.h
new file mode 100644
index 0000000000000..5ba911df843eb
--- /dev/null
+++ b/libcxx/include/__chrono/steady_clock.h
@@ -0,0 +1,44 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// 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_STEADY_CLOCK_H
+#define _LIBCPP___CHRONO_STEADY_CLOCK_H
+
+#include <__chrono/duration.h>
+#include <__chrono/time_point.h>
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace chrono
+{
+
+#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;
+};
+#endif
+
+} // namespace chrono
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___CHRONO_STEADY_CLOCK_H
diff --git a/libcxx/include/__chrono/system_clock.h b/libcxx/include/__chrono/system_clock.h
new file mode 100644
index 0000000000000..9c977d369e1bc
--- /dev/null
+++ b/libcxx/include/__chrono/system_clock.h
@@ -0,0 +1,54 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// 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_SYSTEM_CLOCK_H
+#define _LIBCPP___CHRONO_SYSTEM_CLOCK_H
+
+#include <__chrono/duration.h>
+#include <__chrono/time_point.h>
+#include <__config>
+#include <ctime>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace chrono
+{
+
+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;
+};
+
+#if _LIBCPP_STD_VER > 17
+
+template <class _Duration>
+using sys_time = time_point<system_clock, _Duration>;
+using sys_seconds = sys_time<seconds>;
+using sys_days = sys_time<days>;
+
+#endif
+
+} // namespace chrono
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___CHRONO_SYSTEM_CLOCK_H
diff --git a/libcxx/include/__chrono/time_point.h b/libcxx/include/__chrono/time_point.h
new file mode 100644
index 0000000000000..c042e125145ab
--- /dev/null
+++ b/libcxx/include/__chrono/time_point.h
@@ -0,0 +1,249 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// 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_TIME_POINT_H
+#define _LIBCPP___CHRONO_TIME_POINT_H
+
+#include <__chrono/duration.h>
+#include <__config>
+#include <limits>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace chrono
+{
+
+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
+
+ _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());}
+};
+
+} // namespace 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 // _LIBCPP_STD_VER > 14
+
+// 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();
+}
+
+} // namespace chrono
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___CHRONO_TIME_POINT_H
diff --git a/libcxx/include/__mutex_base b/libcxx/include/__mutex_base
index 21e2075603b55..8d8c8af7070c1 100644
--- a/libcxx/include/__mutex_base
+++ b/libcxx/include/__mutex_base
@@ -13,6 +13,7 @@
#include <__config>
#include <__threading_support>
#include <chrono>
+#include <ratio>
#include <system_error>
#include <time.h>
diff --git a/libcxx/include/__thread/poll_with_backoff.h b/libcxx/include/__thread/poll_with_backoff.h
index e1d8a9c90c56f..3149a38628908 100644
--- a/libcxx/include/__thread/poll_with_backoff.h
+++ b/libcxx/include/__thread/poll_with_backoff.h
@@ -9,6 +9,7 @@
#ifndef _LIBCPP___THREAD_POLL_WITH_BACKOFF_H
#define _LIBCPP___THREAD_POLL_WITH_BACKOFF_H
+#include <__availability>
#include <__config>
#include <chrono>
diff --git a/libcxx/include/chrono b/libcxx/include/chrono
index 90c9b0829a1f5..ee2d63cda7788 100644
--- a/libcxx/include/chrono
+++ b/libcxx/include/chrono
@@ -694,2145 +694,19 @@ constexpr chrono::year operator ""y(unsigned lo
} // std
*/
-#include <__availability>
+#include <__chrono/calendar.h>
+#include <__chrono/duration.h>
+#include <__chrono/file_clock.h>
+#include <__chrono/high_resolution_clock.h>
+#include <__chrono/steady_clock.h>
+#include <__chrono/system_clock.h>
+#include <__chrono/time_point.h>
#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>
-
-#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 {};
-
-} // namespace 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
-#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
-
- _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;
-#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
-
- _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
-
- _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());}
-};
-
-} // namespace 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
-
-#if _LIBCPP_STD_VER > 17
-// [time.clock.file], type file_clock
-using file_clock = _VSTD_FS::_FilesystemClock;
-
-template<class _Duration>
-using file_time = time_point<file_clock, _Duration>;
-
-
-template <class _Duration>
-using sys_time = time_point<system_clock, _Duration>;
-using sys_seconds = sys_time<seconds>;
-using sys_days = sys_time<days>;
-
-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>;
-
-
-struct last_spec { explicit last_spec() = default; };
-
-class day {
-private:
- unsigned char __d;
-public:
- day() = default;
- explicit inline constexpr day(unsigned __val) noexcept : __d(static_cast<unsigned char>(__val)) {}
- inline constexpr day& operator++() noexcept { ++__d; return *this; }
- inline constexpr day operator++(int) noexcept { day __tmp = *this; ++(*this); return __tmp; }
- inline constexpr day& operator--() noexcept { --__d; return *this; }
- inline constexpr day operator--(int) noexcept { day __tmp = *this; --(*this); return __tmp; }
- constexpr day& operator+=(const days& __dd) noexcept;
- constexpr day& operator-=(const days& __dd) noexcept;
- explicit inline constexpr operator unsigned() const noexcept { return __d; }
- inline constexpr bool ok() const noexcept { return __d >= 1 && __d <= 31; }
- };
-
-
-inline constexpr
-bool operator==(const day& __lhs, const day& __rhs) noexcept
-{ return static_cast<unsigned>(__lhs) == static_cast<unsigned>(__rhs); }
-
-inline constexpr
-bool operator!=(const day& __lhs, const day& __rhs) noexcept
-{ return !(__lhs == __rhs); }
-
-inline constexpr
-bool operator< (const day& __lhs, const day& __rhs) noexcept
-{ return static_cast<unsigned>(__lhs) < static_cast<unsigned>(__rhs); }
-
-inline constexpr
-bool operator> (const day& __lhs, const day& __rhs) noexcept
-{ return __rhs < __lhs; }
-
-inline constexpr
-bool operator<=(const day& __lhs, const day& __rhs) noexcept
-{ return !(__rhs < __lhs);}
-
-inline constexpr
-bool operator>=(const day& __lhs, const day& __rhs) noexcept
-{ return !(__lhs < __rhs); }
-
-inline constexpr
-day operator+ (const day& __lhs, const days& __rhs) noexcept
-{ return day(static_cast<unsigned>(__lhs) + __rhs.count()); }
-
-inline constexpr
-day operator+ (const days& __lhs, const day& __rhs) noexcept
-{ return __rhs + __lhs; }
-
-inline constexpr
-day operator- (const day& __lhs, const days& __rhs) noexcept
-{ return __lhs + -__rhs; }
-
-inline constexpr
-days operator-(const day& __lhs, const day& __rhs) noexcept
-{ return days(static_cast<int>(static_cast<unsigned>(__lhs)) -
- static_cast<int>(static_cast<unsigned>(__rhs))); }
-
-inline constexpr day& day::operator+=(const days& __dd) noexcept
-{ *this = *this + __dd; return *this; }
-
-inline constexpr day& day::operator-=(const days& __dd) noexcept
-{ *this = *this - __dd; return *this; }
-
-
-class month {
-private:
- unsigned char __m;
-public:
- month() = default;
- explicit inline constexpr month(unsigned __val) noexcept : __m(static_cast<unsigned char>(__val)) {}
- inline constexpr month& operator++() noexcept { ++__m; return *this; }
- inline constexpr month operator++(int) noexcept { month __tmp = *this; ++(*this); return __tmp; }
- inline constexpr month& operator--() noexcept { --__m; return *this; }
- inline constexpr month operator--(int) noexcept { month __tmp = *this; --(*this); return __tmp; }
- constexpr month& operator+=(const months& __m1) noexcept;
- constexpr month& operator-=(const months& __m1) noexcept;
- explicit inline constexpr operator unsigned() const noexcept { return __m; }
- inline constexpr bool ok() const noexcept { return __m >= 1 && __m <= 12; }
-};
-
-
-inline constexpr
-bool operator==(const month& __lhs, const month& __rhs) noexcept
-{ return static_cast<unsigned>(__lhs) == static_cast<unsigned>(__rhs); }
-
-inline constexpr
-bool operator!=(const month& __lhs, const month& __rhs) noexcept
-{ return !(__lhs == __rhs); }
-
-inline constexpr
-bool operator< (const month& __lhs, const month& __rhs) noexcept
-{ return static_cast<unsigned>(__lhs) < static_cast<unsigned>(__rhs); }
-
-inline constexpr
-bool operator> (const month& __lhs, const month& __rhs) noexcept
-{ return __rhs < __lhs; }
-
-inline constexpr
-bool operator<=(const month& __lhs, const month& __rhs) noexcept
-{ return !(__rhs < __lhs); }
-
-inline constexpr
-bool operator>=(const month& __lhs, const month& __rhs) noexcept
-{ return !(__lhs < __rhs); }
-
-inline constexpr
-month operator+ (const month& __lhs, const months& __rhs) noexcept
-{
- auto const __mu = static_cast<long long>(static_cast<unsigned>(__lhs)) + (__rhs.count() - 1);
- auto const __yr = (__mu >= 0 ? __mu : __mu - 11) / 12;
- return month{static_cast<unsigned>(__mu - __yr * 12 + 1)};
-}
-
-inline constexpr
-month operator+ (const months& __lhs, const month& __rhs) noexcept
-{ return __rhs + __lhs; }
-
-inline constexpr
-month operator- (const month& __lhs, const months& __rhs) noexcept
-{ return __lhs + -__rhs; }
-
-inline constexpr
-months operator-(const month& __lhs, const month& __rhs) noexcept
-{
- auto const __dm = static_cast<unsigned>(__lhs) - static_cast<unsigned>(__rhs);
- return months(__dm <= 11 ? __dm : __dm + 12);
-}
-
-inline constexpr month& month::operator+=(const months& __dm) noexcept
-{ *this = *this + __dm; return *this; }
-
-inline constexpr month& month::operator-=(const months& __dm) noexcept
-{ *this = *this - __dm; return *this; }
-
-
-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; }
- 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 bool is_leap() const noexcept { return __y % 4 == 0 && (__y % 100 != 0 || __y % 400 == 0); }
- explicit inline constexpr operator int() const noexcept { return __y; }
- constexpr bool ok() const noexcept;
- static inline constexpr year min() noexcept { return year{-32767}; }
- static inline constexpr year max() noexcept { return year{ 32767}; }
-};
-
-
-inline constexpr
-bool operator==(const year& __lhs, const year& __rhs) noexcept
-{ return static_cast<int>(__lhs) == static_cast<int>(__rhs); }
-
-inline constexpr
-bool operator!=(const year& __lhs, const year& __rhs) noexcept
-{ return !(__lhs == __rhs); }
-
-inline constexpr
-bool operator< (const year& __lhs, const year& __rhs) noexcept
-{ return static_cast<int>(__lhs) < static_cast<int>(__rhs); }
-
-inline constexpr
-bool operator> (const year& __lhs, const year& __rhs) noexcept
-{ return __rhs < __lhs; }
-
-inline constexpr
-bool operator<=(const year& __lhs, const year& __rhs) noexcept
-{ return !(__rhs < __lhs); }
-
-inline constexpr
-bool operator>=(const year& __lhs, const year& __rhs) noexcept
-{ return !(__lhs < __rhs); }
-
-inline constexpr
-year operator+ (const year& __lhs, const years& __rhs) noexcept
-{ return year(static_cast<int>(__lhs) + __rhs.count()); }
-
-inline constexpr
-year operator+ (const years& __lhs, const year& __rhs) noexcept
-{ return __rhs + __lhs; }
-
-inline constexpr
-year operator- (const year& __lhs, const years& __rhs) noexcept
-{ return __lhs + -__rhs; }
-
-inline constexpr
-years operator-(const year& __lhs, const year& __rhs) noexcept
-{ return years{static_cast<int>(__lhs) - static_cast<int>(__rhs)}; }
-
-
-inline constexpr year& year::operator+=(const years& __dy) noexcept
-{ *this = *this + __dy; return *this; }
-
-inline constexpr year& year::operator-=(const years& __dy) noexcept
-{ *this = *this - __dy; return *this; }
-
-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 {
-private:
- unsigned char __wd;
- static constexpr unsigned char __weekday_from_days(int __days) noexcept;
-public:
- weekday() = default;
- 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
- : __wd(__weekday_from_days(__locd.time_since_epoch().count())) {}
-
- inline constexpr weekday& operator++() noexcept { __wd = (__wd == 6 ? 0 : __wd + 1); return *this; }
- inline constexpr weekday operator++(int) noexcept { weekday __tmp = *this; ++(*this); return __tmp; }
- inline constexpr weekday& operator--() noexcept { __wd = (__wd == 0 ? 6 : __wd - 1); return *this; }
- 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 bool ok() const noexcept { return __wd <= 6; }
- constexpr weekday_indexed operator[](unsigned __index) const noexcept;
- constexpr weekday_last operator[](last_spec) const noexcept;
-};
-
-
-// https://howardhinnant.github.io/date_algorithms.html#weekday_from_days
-inline constexpr
-unsigned char weekday::__weekday_from_days(int __days) noexcept
-{
- return static_cast<unsigned char>(
- static_cast<unsigned>(__days >= -4 ? (__days+4) % 7 : (__days+5) % 7 + 6)
- );
-}
-
-inline constexpr
-bool operator==(const weekday& __lhs, const weekday& __rhs) noexcept
-{ return __lhs.c_encoding() == __rhs.c_encoding(); }
-
-inline constexpr
-bool operator!=(const weekday& __lhs, const weekday& __rhs) noexcept
-{ return !(__lhs == __rhs); }
-
-inline constexpr
-bool operator< (const weekday& __lhs, const weekday& __rhs) noexcept
-{ return __lhs.c_encoding() < __rhs.c_encoding(); }
-
-inline constexpr
-bool operator> (const weekday& __lhs, const weekday& __rhs) noexcept
-{ return __rhs < __lhs; }
-
-inline constexpr
-bool operator<=(const weekday& __lhs, const weekday& __rhs) noexcept
-{ return !(__rhs < __lhs);}
-
-inline constexpr
-bool operator>=(const weekday& __lhs, const weekday& __rhs) noexcept
-{ return !(__lhs < __rhs); }
-
-constexpr weekday operator+(const weekday& __lhs, const days& __rhs) noexcept
-{
- 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)};
-}
-
-constexpr weekday operator+(const days& __lhs, const weekday& __rhs) noexcept
-{ return __rhs + __lhs; }
-
-constexpr weekday operator-(const weekday& __lhs, const days& __rhs) noexcept
-{ return __lhs + -__rhs; }
-
-constexpr days operator-(const weekday& __lhs, const weekday& __rhs) noexcept
-{
- const int __wdu = __lhs.c_encoding() - __rhs.c_encoding();
- const int __wk = (__wdu >= 0 ? __wdu : __wdu-6) / 7;
- return days{__wdu - __wk * 7};
-}
-
-inline constexpr weekday& weekday::operator+=(const days& __dd) noexcept
-{ *this = *this + __dd; return *this; }
-
-inline constexpr weekday& weekday::operator-=(const days& __dd) noexcept
-{ *this = *this - __dd; return *this; }
-
-
-class weekday_indexed {
-private:
- chrono::weekday __wd;
- unsigned char __idx;
-public:
- weekday_indexed() = default;
- 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 unsigned index() const noexcept { return __idx; }
- inline constexpr bool ok() const noexcept { return __wd.ok() && __idx >= 1 && __idx <= 5; }
-};
-
-inline constexpr
-bool operator==(const weekday_indexed& __lhs, const weekday_indexed& __rhs) noexcept
-{ return __lhs.weekday() == __rhs.weekday() && __lhs.index() == __rhs.index(); }
-
-inline constexpr
-bool operator!=(const weekday_indexed& __lhs, const weekday_indexed& __rhs) noexcept
-{ return !(__lhs == __rhs); }
-
-
-class weekday_last {
-private:
- chrono::weekday __wd;
-public:
- explicit constexpr weekday_last(const chrono::weekday& __val) noexcept
- : __wd{__val} {}
- constexpr chrono::weekday weekday() const noexcept { return __wd; }
- constexpr bool ok() const noexcept { return __wd.ok(); }
-};
-
-inline constexpr
-bool operator==(const weekday_last& __lhs, const weekday_last& __rhs) noexcept
-{ return __lhs.weekday() == __rhs.weekday(); }
-
-inline constexpr
-bool operator!=(const weekday_last& __lhs, const weekday_last& __rhs) noexcept
-{ return !(__lhs == __rhs); }
-
-inline constexpr
-weekday_indexed weekday::operator[](unsigned __index) const noexcept { return weekday_indexed{*this, __index}; }
-
-inline constexpr
-weekday_last weekday::operator[](last_spec) const noexcept { return weekday_last{*this}; }
-
-
-inline constexpr last_spec last{};
-inline constexpr weekday Sunday{0};
-inline constexpr weekday Monday{1};
-inline constexpr weekday Tuesday{2};
-inline constexpr weekday Wednesday{3};
-inline constexpr weekday Thursday{4};
-inline constexpr weekday Friday{5};
-inline constexpr weekday Saturday{6};
-
-inline constexpr month January{1};
-inline constexpr month February{2};
-inline constexpr month March{3};
-inline constexpr month April{4};
-inline constexpr month May{5};
-inline constexpr month June{6};
-inline constexpr month July{7};
-inline constexpr month August{8};
-inline constexpr month September{9};
-inline constexpr month October{10};
-inline constexpr month November{11};
-inline constexpr month December{12};
-
-
-class month_day {
-private:
- chrono::month __m;
- chrono::day __d;
-public:
- month_day() = default;
- constexpr month_day(const chrono::month& __mval, const chrono::day& __dval) noexcept
- : __m{__mval}, __d{__dval} {}
- inline constexpr chrono::month month() const noexcept { return __m; }
- inline constexpr chrono::day day() const noexcept { return __d; }
- constexpr bool ok() const noexcept;
-};
-
-inline constexpr
-bool month_day::ok() const noexcept
-{
- if (!__m.ok()) return false;
- const unsigned __dval = static_cast<unsigned>(__d);
- if (__dval < 1 || __dval > 31) return false;
- if (__dval <= 29) return true;
-// Now we've got either 30 or 31
- const unsigned __mval = static_cast<unsigned>(__m);
- if (__mval == 2) return false;
- if (__mval == 4 || __mval == 6 || __mval == 9 || __mval == 11)
- return __dval == 30;
- return true;
-}
-
-inline constexpr
-bool operator==(const month_day& __lhs, const month_day& __rhs) noexcept
-{ return __lhs.month() == __rhs.month() && __lhs.day() == __rhs.day(); }
-
-inline constexpr
-bool operator!=(const month_day& __lhs, const month_day& __rhs) noexcept
-{ return !(__lhs == __rhs); }
-
-inline constexpr
-month_day operator/(const month& __lhs, const day& __rhs) noexcept
-{ return month_day{__lhs, __rhs}; }
-
-constexpr
-month_day operator/(const day& __lhs, const month& __rhs) noexcept
-{ return __rhs / __lhs; }
-
-inline constexpr
-month_day operator/(const month& __lhs, int __rhs) noexcept
-{ return __lhs / day(__rhs); }
-
-constexpr
-month_day operator/(int __lhs, const day& __rhs) noexcept
-{ return month(__lhs) / __rhs; }
-
-constexpr
-month_day operator/(const day& __lhs, int __rhs) noexcept
-{ return month(__rhs) / __lhs; }
-
-
-inline constexpr
-bool operator< (const month_day& __lhs, const month_day& __rhs) noexcept
-{ return __lhs.month() != __rhs.month() ? __lhs.month() < __rhs.month() : __lhs.day() < __rhs.day(); }
-
-inline constexpr
-bool operator> (const month_day& __lhs, const month_day& __rhs) noexcept
-{ return __rhs < __lhs; }
-
-inline constexpr
-bool operator<=(const month_day& __lhs, const month_day& __rhs) noexcept
-{ return !(__rhs < __lhs);}
-
-inline constexpr
-bool operator>=(const month_day& __lhs, const month_day& __rhs) noexcept
-{ return !(__lhs < __rhs); }
-
-
-
-class month_day_last {
-private:
- chrono::month __m;
-public:
- explicit constexpr month_day_last(const chrono::month& __val) noexcept
- : __m{__val} {}
- inline constexpr chrono::month month() const noexcept { return __m; }
- inline constexpr bool ok() const noexcept { return __m.ok(); }
-};
-
-inline constexpr
-bool operator==(const month_day_last& __lhs, const month_day_last& __rhs) noexcept
-{ return __lhs.month() == __rhs.month(); }
-
-inline constexpr
-bool operator!=(const month_day_last& __lhs, const month_day_last& __rhs) noexcept
-{ return !(__lhs == __rhs); }
-
-inline constexpr
-bool operator< (const month_day_last& __lhs, const month_day_last& __rhs) noexcept
-{ return __lhs.month() < __rhs.month(); }
-
-inline constexpr
-bool operator> (const month_day_last& __lhs, const month_day_last& __rhs) noexcept
-{ return __rhs < __lhs; }
-
-inline constexpr
-bool operator<=(const month_day_last& __lhs, const month_day_last& __rhs) noexcept
-{ return !(__rhs < __lhs);}
-
-inline constexpr
-bool operator>=(const month_day_last& __lhs, const month_day_last& __rhs) noexcept
-{ return !(__lhs < __rhs); }
-
-inline constexpr
-month_day_last operator/(const month& __lhs, last_spec) noexcept
-{ return month_day_last{__lhs}; }
-
-inline constexpr
-month_day_last operator/(last_spec, const month& __rhs) noexcept
-{ return month_day_last{__rhs}; }
-
-inline constexpr
-month_day_last operator/(int __lhs, last_spec) noexcept
-{ return month_day_last{month(__lhs)}; }
-
-inline constexpr
-month_day_last operator/(last_spec, int __rhs) noexcept
-{ return month_day_last{month(__rhs)}; }
-
-
-class month_weekday {
-private:
- chrono::month __m;
- chrono::weekday_indexed __wdi;
-public:
- month_weekday() = default;
- constexpr month_weekday(const chrono::month& __mval, const chrono::weekday_indexed& __wdival) noexcept
- : __m{__mval}, __wdi{__wdival} {}
- inline constexpr chrono::month month() const noexcept { return __m; }
- inline constexpr chrono::weekday_indexed weekday_indexed() const noexcept { return __wdi; }
- inline constexpr bool ok() const noexcept { return __m.ok() && __wdi.ok(); }
-};
-
-inline constexpr
-bool operator==(const month_weekday& __lhs, const month_weekday& __rhs) noexcept
-{ return __lhs.month() == __rhs.month() && __lhs.weekday_indexed() == __rhs.weekday_indexed(); }
-
-inline constexpr
-bool operator!=(const month_weekday& __lhs, const month_weekday& __rhs) noexcept
-{ return !(__lhs == __rhs); }
-
-inline constexpr
-month_weekday operator/(const month& __lhs, const weekday_indexed& __rhs) noexcept
-{ return month_weekday{__lhs, __rhs}; }
-
-inline constexpr
-month_weekday operator/(int __lhs, const weekday_indexed& __rhs) noexcept
-{ return month_weekday{month(__lhs), __rhs}; }
-
-inline constexpr
-month_weekday operator/(const weekday_indexed& __lhs, const month& __rhs) noexcept
-{ return month_weekday{__rhs, __lhs}; }
-
-inline constexpr
-month_weekday operator/(const weekday_indexed& __lhs, int __rhs) noexcept
-{ return month_weekday{month(__rhs), __lhs}; }
-
-
-class month_weekday_last {
- chrono::month __m;
- chrono::weekday_last __wdl;
- public:
- constexpr month_weekday_last(const chrono::month& __mval, const chrono::weekday_last& __wdlval) noexcept
- : __m{__mval}, __wdl{__wdlval} {}
- inline constexpr chrono::month month() const noexcept { return __m; }
- inline constexpr chrono::weekday_last weekday_last() const noexcept { return __wdl; }
- inline constexpr bool ok() const noexcept { return __m.ok() && __wdl.ok(); }
-};
-
-inline constexpr
-bool operator==(const month_weekday_last& __lhs, const month_weekday_last& __rhs) noexcept
-{ return __lhs.month() == __rhs.month() && __lhs.weekday_last() == __rhs.weekday_last(); }
-
-inline constexpr
-bool operator!=(const month_weekday_last& __lhs, const month_weekday_last& __rhs) noexcept
-{ return !(__lhs == __rhs); }
-
-
-inline constexpr
-month_weekday_last operator/(const month& __lhs, const weekday_last& __rhs) noexcept
-{ return month_weekday_last{__lhs, __rhs}; }
-
-inline constexpr
-month_weekday_last operator/(int __lhs, const weekday_last& __rhs) noexcept
-{ return month_weekday_last{month(__lhs), __rhs}; }
-
-inline constexpr
-month_weekday_last operator/(const weekday_last& __lhs, const month& __rhs) noexcept
-{ return month_weekday_last{__rhs, __lhs}; }
-
-inline constexpr
-month_weekday_last operator/(const weekday_last& __lhs, int __rhs) noexcept
-{ return month_weekday_last{month(__rhs), __lhs}; }
-
-
-class year_month {
- chrono::year __y;
- chrono::month __m;
-public:
- year_month() = default;
- constexpr year_month(const chrono::year& __yval, const chrono::month& __mval) noexcept
- : __y{__yval}, __m{__mval} {}
- inline constexpr chrono::year year() const noexcept { return __y; }
- inline constexpr chrono::month month() const noexcept { return __m; }
- inline constexpr year_month& operator+=(const months& __dm) noexcept { this->__m += __dm; return *this; }
- inline constexpr year_month& operator-=(const months& __dm) noexcept { this->__m -= __dm; return *this; }
- inline constexpr year_month& operator+=(const years& __dy) noexcept { this->__y += __dy; return *this; }
- inline constexpr year_month& operator-=(const years& __dy) noexcept { this->__y -= __dy; return *this; }
- inline constexpr bool ok() const noexcept { return __y.ok() && __m.ok(); }
-};
-
-inline constexpr
-year_month operator/(const year& __y, const month& __m) noexcept { return year_month{__y, __m}; }
-
-inline constexpr
-year_month operator/(const year& __y, int __m) noexcept { return year_month{__y, month(__m)}; }
-
-inline constexpr
-bool operator==(const year_month& __lhs, const year_month& __rhs) noexcept
-{ return __lhs.year() == __rhs.year() && __lhs.month() == __rhs.month(); }
-
-inline constexpr
-bool operator!=(const year_month& __lhs, const year_month& __rhs) noexcept
-{ return !(__lhs == __rhs); }
-
-inline constexpr
-bool operator< (const year_month& __lhs, const year_month& __rhs) noexcept
-{ return __lhs.year() != __rhs.year() ? __lhs.year() < __rhs.year() : __lhs.month() < __rhs.month(); }
-
-inline constexpr
-bool operator> (const year_month& __lhs, const year_month& __rhs) noexcept
-{ return __rhs < __lhs; }
-
-inline constexpr
-bool operator<=(const year_month& __lhs, const year_month& __rhs) noexcept
-{ return !(__rhs < __lhs);}
-
-inline constexpr
-bool operator>=(const year_month& __lhs, const year_month& __rhs) noexcept
-{ return !(__lhs < __rhs); }
-
-constexpr year_month operator+(const year_month& __lhs, const months& __rhs) noexcept
-{
- int __dmi = static_cast<int>(static_cast<unsigned>(__lhs.month())) - 1 + __rhs.count();
- const int __dy = (__dmi >= 0 ? __dmi : __dmi-11) / 12;
- __dmi = __dmi - __dy * 12 + 1;
- return (__lhs.year() + years(__dy)) / month(static_cast<unsigned>(__dmi));
-}
-
-constexpr year_month operator+(const months& __lhs, const year_month& __rhs) noexcept
-{ return __rhs + __lhs; }
-
-constexpr year_month operator+(const year_month& __lhs, const years& __rhs) noexcept
-{ return (__lhs.year() + __rhs) / __lhs.month(); }
-
-constexpr year_month operator+(const years& __lhs, const year_month& __rhs) noexcept
-{ return __rhs + __lhs; }
-
-constexpr months operator-(const year_month& __lhs, const year_month& __rhs) noexcept
-{ return (__lhs.year() - __rhs.year()) + months(static_cast<unsigned>(__lhs.month()) - static_cast<unsigned>(__rhs.month())); }
-
-constexpr year_month operator-(const year_month& __lhs, const months& __rhs) noexcept
-{ return __lhs + -__rhs; }
-
-constexpr year_month operator-(const year_month& __lhs, const years& __rhs) noexcept
-{ return __lhs + -__rhs; }
-
-class year_month_day_last;
-
-class year_month_day {
-private:
- chrono::year __y;
- chrono::month __m;
- chrono::day __d;
-public:
- year_month_day() = default;
- inline constexpr year_month_day(
- const chrono::year& __yval, const chrono::month& __mval, const chrono::day& __dval) noexcept
- : __y{__yval}, __m{__mval}, __d{__dval} {}
- constexpr year_month_day(const year_month_day_last& __ymdl) noexcept;
- inline constexpr year_month_day(const sys_days& __sysd) noexcept
- : year_month_day(__from_days(__sysd.time_since_epoch())) {}
- inline explicit constexpr year_month_day(const local_days& __locd) noexcept
- : year_month_day(__from_days(__locd.time_since_epoch())) {}
-
- constexpr year_month_day& operator+=(const months& __dm) noexcept;
- constexpr year_month_day& operator-=(const months& __dm) noexcept;
- constexpr year_month_day& operator+=(const years& __dy) noexcept;
- constexpr year_month_day& operator-=(const years& __dy) noexcept;
-
- inline constexpr chrono::year year() const noexcept { return __y; }
- inline constexpr chrono::month month() const noexcept { return __m; }
- inline constexpr chrono::day day() const noexcept { return __d; }
- inline constexpr operator sys_days() const noexcept { return sys_days{__to_days()}; }
- inline explicit constexpr operator local_days() const noexcept { return local_days{__to_days()}; }
-
- constexpr bool ok() const noexcept;
-
- static constexpr year_month_day __from_days(days __d) noexcept;
- constexpr days __to_days() const noexcept;
-};
-
-
-// https://howardhinnant.github.io/date_algorithms.html#civil_from_days
-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 , "");
- 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]
- const unsigned __yoe = (__doe - __doe/1460 + __doe/36524 - __doe/146096) / 365; // [0, 399]
- const int __yr = static_cast<int>(__yoe) + __era * 400;
- const unsigned __doy = __doe - (365 * __yoe + __yoe/4 - __yoe/100); // [0, 365]
- const unsigned __mp = (5 * __doy + 2)/153; // [0, 11]
- const unsigned __dy = __doy - (153 * __mp + 2)/5 + 1; // [1, 31]
- const unsigned __mth = __mp + (__mp < 10 ? 3 : -9); // [1, 12]
- return year_month_day{chrono::year{__yr + (__mth <= 2)}, chrono::month{__mth}, chrono::day{__dy}};
-}
-
-// 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 , "");
-
- const int __yr = static_cast<int>(__y) - (__m <= February);
- const unsigned __mth = static_cast<unsigned>(__m);
- const unsigned __dy = static_cast<unsigned>(__d);
-
- const int __era = (__yr >= 0 ? __yr : __yr - 399) / 400;
- const unsigned __yoe = static_cast<unsigned>(__yr - __era * 400); // [0, 399]
- const unsigned __doy = (153 * (__mth + (__mth > 2 ? -3 : 9)) + 2) / 5 + __dy-1; // [0, 365]
- const unsigned __doe = __yoe * 365 + __yoe/4 - __yoe/100 + __doy; // [0, 146096]
- return days{__era * 146097 + static_cast<int>(__doe) - 719468};
-}
-
-inline constexpr
-bool operator==(const year_month_day& __lhs, const year_month_day& __rhs) noexcept
-{ return __lhs.year() == __rhs.year() && __lhs.month() == __rhs.month() && __lhs.day() == __rhs.day(); }
-
-inline constexpr
-bool operator!=(const year_month_day& __lhs, const year_month_day& __rhs) noexcept
-{ return !(__lhs == __rhs); }
-
-inline constexpr
-bool operator< (const year_month_day& __lhs, const year_month_day& __rhs) noexcept
-{
- if (__lhs.year() < __rhs.year()) return true;
- if (__lhs.year() > __rhs.year()) return false;
- if (__lhs.month() < __rhs.month()) return true;
- if (__lhs.month() > __rhs.month()) return false;
- return __lhs.day() < __rhs.day();
-}
-
-inline constexpr
-bool operator> (const year_month_day& __lhs, const year_month_day& __rhs) noexcept
-{ return __rhs < __lhs; }
-
-inline constexpr
-bool operator<=(const year_month_day& __lhs, const year_month_day& __rhs) noexcept
-{ return !(__rhs < __lhs);}
-
-inline constexpr
-bool operator>=(const year_month_day& __lhs, const year_month_day& __rhs) noexcept
-{ return !(__lhs < __rhs); }
-
-inline constexpr
-year_month_day operator/(const year_month& __lhs, const day& __rhs) noexcept
-{ return year_month_day{__lhs.year(), __lhs.month(), __rhs}; }
-
-inline constexpr
-year_month_day operator/(const year_month& __lhs, int __rhs) noexcept
-{ return __lhs / day(__rhs); }
-
-inline constexpr
-year_month_day operator/(const year& __lhs, const month_day& __rhs) noexcept
-{ return __lhs / __rhs.month() / __rhs.day(); }
-
-inline constexpr
-year_month_day operator/(int __lhs, const month_day& __rhs) noexcept
-{ return year(__lhs) / __rhs; }
-
-inline constexpr
-year_month_day operator/(const month_day& __lhs, const year& __rhs) noexcept
-{ return __rhs / __lhs; }
-
-inline constexpr
-year_month_day operator/(const month_day& __lhs, int __rhs) noexcept
-{ return year(__rhs) / __lhs; }
-
-
-inline constexpr
-year_month_day operator+(const year_month_day& __lhs, const months& __rhs) noexcept
-{ return (__lhs.year()/__lhs.month() + __rhs)/__lhs.day(); }
-
-inline constexpr
-year_month_day operator+(const months& __lhs, const year_month_day& __rhs) noexcept
-{ return __rhs + __lhs; }
-
-inline constexpr
-year_month_day operator-(const year_month_day& __lhs, const months& __rhs) noexcept
-{ return __lhs + -__rhs; }
-
-inline constexpr
-year_month_day operator+(const year_month_day& __lhs, const years& __rhs) noexcept
-{ return (__lhs.year() + __rhs) / __lhs.month() / __lhs.day(); }
-
-inline constexpr
-year_month_day operator+(const years& __lhs, const year_month_day& __rhs) noexcept
-{ return __rhs + __lhs; }
-
-inline constexpr
-year_month_day operator-(const year_month_day& __lhs, const years& __rhs) noexcept
-{ return __lhs + -__rhs; }
-
-inline constexpr year_month_day& year_month_day::operator+=(const months& __dm) noexcept { *this = *this + __dm; return *this; }
-inline constexpr year_month_day& year_month_day::operator-=(const months& __dm) noexcept { *this = *this - __dm; return *this; }
-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 {
-private:
- chrono::year __y;
- chrono::month_day_last __mdl;
-public:
- constexpr year_month_day_last(const year& __yval, const month_day_last& __mdlval) noexcept
- : __y{__yval}, __mdl{__mdlval} {}
-
- constexpr year_month_day_last& operator+=(const months& __m) noexcept;
- constexpr year_month_day_last& operator-=(const months& __m) noexcept;
- constexpr year_month_day_last& operator+=(const years& __y) noexcept;
- constexpr year_month_day_last& operator-=(const years& __y) noexcept;
-
- inline constexpr chrono::year year() const noexcept { return __y; }
- inline constexpr chrono::month month() const noexcept { return __mdl.month(); }
- inline constexpr chrono::month_day_last month_day_last() const noexcept { return __mdl; }
- constexpr chrono::day day() const noexcept;
- inline constexpr operator sys_days() const noexcept { return sys_days{year()/month()/day()}; }
- inline explicit constexpr operator local_days() const noexcept { return local_days{year()/month()/day()}; }
- inline constexpr bool ok() const noexcept { return __y.ok() && __mdl.ok(); }
-};
-
-inline constexpr
-chrono::day year_month_day_last::day() const noexcept
-{
- constexpr chrono::day __d[] =
- {
- chrono::day(31), chrono::day(28), chrono::day(31),
- chrono::day(30), chrono::day(31), chrono::day(30),
- 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() ?
- __d[static_cast<unsigned>(month()) - 1] : chrono::day{29};
-}
-
-inline constexpr
-bool operator==(const year_month_day_last& __lhs, const year_month_day_last& __rhs) noexcept
-{ return __lhs.year() == __rhs.year() && __lhs.month_day_last() == __rhs.month_day_last(); }
-
-inline constexpr
-bool operator!=(const year_month_day_last& __lhs, const year_month_day_last& __rhs) noexcept
-{ return !(__lhs == __rhs); }
-
-inline constexpr
-bool operator< (const year_month_day_last& __lhs, const year_month_day_last& __rhs) noexcept
-{
- if (__lhs.year() < __rhs.year()) return true;
- if (__lhs.year() > __rhs.year()) return false;
- return __lhs.month_day_last() < __rhs.month_day_last();
-}
-
-inline constexpr
-bool operator> (const year_month_day_last& __lhs, const year_month_day_last& __rhs) noexcept
-{ return __rhs < __lhs; }
-
-inline constexpr
-bool operator<=(const year_month_day_last& __lhs, const year_month_day_last& __rhs) noexcept
-{ return !(__rhs < __lhs);}
-
-inline constexpr
-bool operator>=(const year_month_day_last& __lhs, const year_month_day_last& __rhs) noexcept
-{ return !(__lhs < __rhs); }
-
-inline constexpr year_month_day_last operator/(const year_month& __lhs, last_spec) noexcept
-{ return year_month_day_last{__lhs.year(), month_day_last{__lhs.month()}}; }
-
-inline constexpr year_month_day_last operator/(const year& __lhs, const month_day_last& __rhs) noexcept
-{ return year_month_day_last{__lhs, __rhs}; }
-
-inline constexpr year_month_day_last operator/(int __lhs, const month_day_last& __rhs) noexcept
-{ return year_month_day_last{year{__lhs}, __rhs}; }
-
-inline constexpr year_month_day_last operator/(const month_day_last& __lhs, const year& __rhs) noexcept
-{ return __rhs / __lhs; }
-
-inline constexpr year_month_day_last operator/(const month_day_last& __lhs, int __rhs) noexcept
-{ return year{__rhs} / __lhs; }
-
-
-inline constexpr
-year_month_day_last operator+(const year_month_day_last& __lhs, const months& __rhs) noexcept
-{ return (__lhs.year() / __lhs.month() + __rhs) / last; }
-
-inline constexpr
-year_month_day_last operator+(const months& __lhs, const year_month_day_last& __rhs) noexcept
-{ return __rhs + __lhs; }
-
-inline constexpr
-year_month_day_last operator-(const year_month_day_last& __lhs, const months& __rhs) noexcept
-{ return __lhs + (-__rhs); }
-
-inline constexpr
-year_month_day_last operator+(const year_month_day_last& __lhs, const years& __rhs) noexcept
-{ return year_month_day_last{__lhs.year() + __rhs, __lhs.month_day_last()}; }
-
-inline constexpr
-year_month_day_last operator+(const years& __lhs, const year_month_day_last& __rhs) noexcept
-{ return __rhs + __lhs; }
-
-inline constexpr
-year_month_day_last operator-(const year_month_day_last& __lhs, const years& __rhs) noexcept
-{ return __lhs + (-__rhs); }
-
-inline constexpr year_month_day_last& year_month_day_last::operator+=(const months& __dm) noexcept { *this = *this + __dm; return *this; }
-inline constexpr year_month_day_last& year_month_day_last::operator-=(const months& __dm) noexcept { *this = *this - __dm; return *this; }
-inline constexpr year_month_day_last& year_month_day_last::operator+=(const years& __dy) noexcept { *this = *this + __dy; return *this; }
-inline constexpr year_month_day_last& year_month_day_last::operator-=(const years& __dy) noexcept { *this = *this - __dy; return *this; }
-
-inline constexpr year_month_day::year_month_day(const year_month_day_last& __ymdl) noexcept
- : __y{__ymdl.year()}, __m{__ymdl.month()}, __d{__ymdl.day()} {}
-
-inline constexpr bool year_month_day::ok() const noexcept
-{
- if (!__y.ok() || !__m.ok()) return false;
- return chrono::day{1} <= __d && __d <= (__y / __m / last).day();
-}
-
-class year_month_weekday {
- chrono::year __y;
- chrono::month __m;
- chrono::weekday_indexed __wdi;
-public:
- year_month_weekday() = default;
- constexpr year_month_weekday(const chrono::year& __yval, const chrono::month& __mval,
- const chrono::weekday_indexed& __wdival) noexcept
- : __y{__yval}, __m{__mval}, __wdi{__wdival} {}
- constexpr year_month_weekday(const sys_days& __sysd) noexcept
- : year_month_weekday(__from_days(__sysd.time_since_epoch())) {}
- inline explicit constexpr year_month_weekday(const local_days& __locd) noexcept
- : year_month_weekday(__from_days(__locd.time_since_epoch())) {}
- constexpr year_month_weekday& operator+=(const months& m) noexcept;
- constexpr year_month_weekday& operator-=(const months& m) noexcept;
- constexpr year_month_weekday& operator+=(const years& y) noexcept;
- constexpr year_month_weekday& operator-=(const years& y) noexcept;
-
- inline constexpr chrono::year year() const noexcept { return __y; }
- inline constexpr chrono::month month() const noexcept { return __m; }
- inline constexpr chrono::weekday weekday() const noexcept { return __wdi.weekday(); }
- inline constexpr unsigned index() const noexcept { return __wdi.index(); }
- inline constexpr chrono::weekday_indexed weekday_indexed() const noexcept { return __wdi; }
-
- inline constexpr operator sys_days() const noexcept { return sys_days{__to_days()}; }
- inline explicit constexpr operator local_days() const noexcept { return local_days{__to_days()}; }
- 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());
- }
-
- static constexpr year_month_weekday __from_days(days __d) noexcept;
- constexpr days __to_days() const noexcept;
-};
-
-inline constexpr
-year_month_weekday year_month_weekday::__from_days(days __d) noexcept
-{
- const sys_days __sysd{__d};
- const chrono::weekday __wd = chrono::weekday(__sysd);
- const year_month_day __ymd = year_month_day(__sysd);
- return year_month_weekday{__ymd.year(), __ymd.month(),
- __wd[(static_cast<unsigned>(__ymd.day())-1)/7+1]};
-}
-
-inline constexpr
-days year_month_weekday::__to_days() const noexcept
-{
- const sys_days __sysd = sys_days(__y/__m/1);
- return (__sysd + (__wdi.weekday() - chrono::weekday(__sysd) + days{(__wdi.index()-1)*7}))
- .time_since_epoch();
-}
-
-inline constexpr
-bool operator==(const year_month_weekday& __lhs, const year_month_weekday& __rhs) noexcept
-{ return __lhs.year() == __rhs.year() && __lhs.month() == __rhs.month() && __lhs.weekday_indexed() == __rhs.weekday_indexed(); }
-
-inline constexpr
-bool operator!=(const year_month_weekday& __lhs, const year_month_weekday& __rhs) noexcept
-{ return !(__lhs == __rhs); }
-
-inline constexpr
-year_month_weekday operator/(const year_month& __lhs, const weekday_indexed& __rhs) noexcept
-{ return year_month_weekday{__lhs.year(), __lhs.month(), __rhs}; }
-
-inline constexpr
-year_month_weekday operator/(const year& __lhs, const month_weekday& __rhs) noexcept
-{ return year_month_weekday{__lhs, __rhs.month(), __rhs.weekday_indexed()}; }
-
-inline constexpr
-year_month_weekday operator/(int __lhs, const month_weekday& __rhs) noexcept
-{ return year(__lhs) / __rhs; }
-
-inline constexpr
-year_month_weekday operator/(const month_weekday& __lhs, const year& __rhs) noexcept
-{ return __rhs / __lhs; }
-
-inline constexpr
-year_month_weekday operator/(const month_weekday& __lhs, int __rhs) noexcept
-{ return year(__rhs) / __lhs; }
-
-
-inline constexpr
-year_month_weekday operator+(const year_month_weekday& __lhs, const months& __rhs) noexcept
-{ return (__lhs.year() / __lhs.month() + __rhs) / __lhs.weekday_indexed(); }
-
-inline constexpr
-year_month_weekday operator+(const months& __lhs, const year_month_weekday& __rhs) noexcept
-{ return __rhs + __lhs; }
-
-inline constexpr
-year_month_weekday operator-(const year_month_weekday& __lhs, const months& __rhs) noexcept
-{ return __lhs + (-__rhs); }
-
-inline constexpr
-year_month_weekday operator+(const year_month_weekday& __lhs, const years& __rhs) noexcept
-{ return year_month_weekday{__lhs.year() + __rhs, __lhs.month(), __lhs.weekday_indexed()}; }
-
-inline constexpr
-year_month_weekday operator+(const years& __lhs, const year_month_weekday& __rhs) noexcept
-{ return __rhs + __lhs; }
-
-inline constexpr
-year_month_weekday operator-(const year_month_weekday& __lhs, const years& __rhs) noexcept
-{ return __lhs + (-__rhs); }
-
-
-inline constexpr year_month_weekday& year_month_weekday::operator+=(const months& __dm) noexcept { *this = *this + __dm; return *this; }
-inline constexpr year_month_weekday& year_month_weekday::operator-=(const months& __dm) noexcept { *this = *this - __dm; return *this; }
-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 {
-private:
- chrono::year __y;
- chrono::month __m;
- chrono::weekday_last __wdl;
-public:
- constexpr year_month_weekday_last(const chrono::year& __yval, const chrono::month& __mval,
- const chrono::weekday_last& __wdlval) noexcept
- : __y{__yval}, __m{__mval}, __wdl{__wdlval} {}
- constexpr year_month_weekday_last& operator+=(const months& __dm) noexcept;
- constexpr year_month_weekday_last& operator-=(const months& __dm) noexcept;
- constexpr year_month_weekday_last& operator+=(const years& __dy) noexcept;
- constexpr year_month_weekday_last& operator-=(const years& __dy) noexcept;
-
- inline constexpr chrono::year year() const noexcept { return __y; }
- inline constexpr chrono::month month() const noexcept { return __m; }
- inline constexpr chrono::weekday weekday() const noexcept { return __wdl.weekday(); }
- inline constexpr chrono::weekday_last weekday_last() const noexcept { return __wdl; }
- inline constexpr operator sys_days() const noexcept { return sys_days{__to_days()}; }
- inline explicit constexpr operator local_days() const noexcept { return local_days{__to_days()}; }
- inline constexpr bool ok() const noexcept { return __y.ok() && __m.ok() && __wdl.ok(); }
-
- constexpr days __to_days() const noexcept;
-
-};
-
-inline constexpr
-days year_month_weekday_last::__to_days() const noexcept
-{
- const sys_days __last = sys_days{__y/__m/last};
- return (__last - (chrono::weekday{__last} - __wdl.weekday())).time_since_epoch();
-
-}
-
-inline constexpr
-bool operator==(const year_month_weekday_last& __lhs, const year_month_weekday_last& __rhs) noexcept
-{ return __lhs.year() == __rhs.year() && __lhs.month() == __rhs.month() && __lhs.weekday_last() == __rhs.weekday_last(); }
-
-inline constexpr
-bool operator!=(const year_month_weekday_last& __lhs, const year_month_weekday_last& __rhs) noexcept
-{ return !(__lhs == __rhs); }
-
-
-inline constexpr
-year_month_weekday_last operator/(const year_month& __lhs, const weekday_last& __rhs) noexcept
-{ return year_month_weekday_last{__lhs.year(), __lhs.month(), __rhs}; }
-
-inline constexpr
-year_month_weekday_last operator/(const year& __lhs, const month_weekday_last& __rhs) noexcept
-{ return year_month_weekday_last{__lhs, __rhs.month(), __rhs.weekday_last()}; }
-
-inline constexpr
-year_month_weekday_last operator/(int __lhs, const month_weekday_last& __rhs) noexcept
-{ return year(__lhs) / __rhs; }
-
-inline constexpr
-year_month_weekday_last operator/(const month_weekday_last& __lhs, const year& __rhs) noexcept
-{ return __rhs / __lhs; }
-
-inline constexpr
-year_month_weekday_last operator/(const month_weekday_last& __lhs, int __rhs) noexcept
-{ return year(__rhs) / __lhs; }
-
-
-inline constexpr
-year_month_weekday_last operator+(const year_month_weekday_last& __lhs, const months& __rhs) noexcept
-{ return (__lhs.year() / __lhs.month() + __rhs) / __lhs.weekday_last(); }
-
-inline constexpr
-year_month_weekday_last operator+(const months& __lhs, const year_month_weekday_last& __rhs) noexcept
-{ return __rhs + __lhs; }
-
-inline constexpr
-year_month_weekday_last operator-(const year_month_weekday_last& __lhs, const months& __rhs) noexcept
-{ return __lhs + (-__rhs); }
-
-inline constexpr
-year_month_weekday_last operator+(const year_month_weekday_last& __lhs, const years& __rhs) noexcept
-{ return year_month_weekday_last{__lhs.year() + __rhs, __lhs.month(), __lhs.weekday_last()}; }
-
-inline constexpr
-year_month_weekday_last operator+(const years& __lhs, const year_month_weekday_last& __rhs) noexcept
-{ return __rhs + __lhs; }
-
-inline constexpr
-year_month_weekday_last operator-(const year_month_weekday_last& __lhs, const years& __rhs) noexcept
-{ return __lhs + (-__rhs); }
-
-inline constexpr year_month_weekday_last& year_month_weekday_last::operator+=(const months& __dm) noexcept { *this = *this + __dm; return *this; }
-inline constexpr year_month_weekday_last& year_month_weekday_last::operator-=(const months& __dm) noexcept { *this = *this - __dm; return *this; }
-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;
-}
-
-#endif // _LIBCPP_STD_VER > 17
-} // namespace 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));
- }
-
- constexpr chrono::duration<long double, ratio<3600,1>> operator""h(long double __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));
- }
-
- constexpr chrono::duration<long double, ratio<60,1>> operator""min(long double __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));
- }
-
- constexpr chrono::duration<long double> operator""s(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));
- }
-
- constexpr chrono::duration<long double, milli> operator""ms(long double __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));
- }
-
- constexpr chrono::duration<long double, micro> operator""us(long double __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));
- }
-
- constexpr chrono::duration<long double, nano> operator""ns(long double __ns)
- {
- 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));
- }
-
- constexpr chrono::year operator ""y(unsigned long long __y) noexcept
- {
- return chrono::year(static_cast<int>(__y));
- }
-#endif
-} // namespace chrono_literals
-} // namespace literals
-
-namespace chrono { // hoist the literals into namespace std::chrono
- using namespace literals::chrono_literals;
-} // namespace chrono
-
-#endif
-
-_LIBCPP_END_NAMESPACE_STD
-
-#ifndef _LIBCPP_CXX03_LANG
-_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
-struct _FilesystemClock {
-#if !defined(_LIBCPP_HAS_NO_INT128)
- typedef __int128_t rep;
- typedef nano period;
-#else
- typedef long long rep;
- typedef nano period;
-#endif
-
- typedef chrono::duration<rep, period> duration;
- typedef chrono::time_point<_FilesystemClock> time_point;
-
- _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;
-
-#if _LIBCPP_STD_VER > 17
- template <class _Duration>
- _LIBCPP_HIDE_FROM_ABI
- static chrono::sys_time<_Duration> to_sys(const chrono::file_time<_Duration>& __t) {
- return chrono::sys_time<_Duration>(__t.time_since_epoch());
- }
-
- template <class _Duration>
- _LIBCPP_HIDE_FROM_ABI
- static chrono::file_time<_Duration> from_sys(const chrono::sys_time<_Duration>& __t) {
- return chrono::file_time<_Duration>(__t.time_since_epoch());
- }
-#endif // _LIBCPP_STD_VER > 17
-};
-_LIBCPP_END_NAMESPACE_FILESYSTEM
-#endif // !_LIBCPP_CXX03_LANG
-
-_LIBCPP_POP_MACROS
-
#endif // _LIBCPP_CHRONO
diff --git a/libcxx/include/module.modulemap b/libcxx/include/module.modulemap
index e7f197ec83f22..33e0ecf699748 100644
--- a/libcxx/include/module.modulemap
+++ b/libcxx/include/module.modulemap
@@ -364,6 +364,16 @@ module std [system] {
module chrono {
header "chrono"
export *
+
+ module __chrono {
+ module calendar { private header "__chrono/calendar.h" }
+ module duration { private header "__chrono/duration.h" }
+ module file_clock { private header "__chrono/file_clock.h" }
+ module high_resolution_clock { private header "__chrono/high_resolution_clock.h" }
+ module steady_clock { private header "__chrono/steady_clock.h" }
+ module system_clock { private header "__chrono/system_clock.h" }
+ module time_point { private header "__chrono/time_point.h" }
+ }
}
module codecvt {
header "codecvt"
diff --git a/libcxx/include/streambuf b/libcxx/include/streambuf
index aa66370f1b687..9874ec2ce499b 100644
--- a/libcxx/include/streambuf
+++ b/libcxx/include/streambuf
@@ -108,6 +108,7 @@ protected:
*/
#include <__config>
+#include <cstdint>
#include <ios>
#include <iosfwd>
#include <version>
diff --git a/libcxx/src/filesystem/filesystem_common.h b/libcxx/src/filesystem/filesystem_common.h
index 717894e537d24..ef4f02e6afb2e 100644
--- a/libcxx/src/filesystem/filesystem_common.h
+++ b/libcxx/src/filesystem/filesystem_common.h
@@ -17,6 +17,7 @@
#include "cstdlib"
#include "ctime"
#include "filesystem"
+#include "ratio"
#include "system_error"
#if !defined(_LIBCPP_WIN32API)
diff --git a/libcxx/test/libcxx/diagnostics/detail.headers/chrono/calendar.module.verify.cpp b/libcxx/test/libcxx/diagnostics/detail.headers/chrono/calendar.module.verify.cpp
new file mode 100644
index 0000000000000..5e8cf1638fe6e
--- /dev/null
+++ b/libcxx/test/libcxx/diagnostics/detail.headers/chrono/calendar.module.verify.cpp
@@ -0,0 +1,15 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: modules-build
+
+// WARNING: This test was generated by 'generate_private_header_tests.py'
+// and should not be edited manually.
+
+// expected-error@*:* {{use of private header from outside its module: '__chrono/calendar.h'}}
+#include <__chrono/calendar.h>
diff --git a/libcxx/test/libcxx/diagnostics/detail.headers/chrono/duration.module.verify.cpp b/libcxx/test/libcxx/diagnostics/detail.headers/chrono/duration.module.verify.cpp
new file mode 100644
index 0000000000000..943e10c2035bb
--- /dev/null
+++ b/libcxx/test/libcxx/diagnostics/detail.headers/chrono/duration.module.verify.cpp
@@ -0,0 +1,15 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: modules-build
+
+// WARNING: This test was generated by 'generate_private_header_tests.py'
+// and should not be edited manually.
+
+// expected-error@*:* {{use of private header from outside its module: '__chrono/duration.h'}}
+#include <__chrono/duration.h>
diff --git a/libcxx/test/libcxx/diagnostics/detail.headers/chrono/file_clock.module.verify.cpp b/libcxx/test/libcxx/diagnostics/detail.headers/chrono/file_clock.module.verify.cpp
new file mode 100644
index 0000000000000..e8b17ab632c01
--- /dev/null
+++ b/libcxx/test/libcxx/diagnostics/detail.headers/chrono/file_clock.module.verify.cpp
@@ -0,0 +1,15 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: modules-build
+
+// WARNING: This test was generated by 'generate_private_header_tests.py'
+// and should not be edited manually.
+
+// expected-error@*:* {{use of private header from outside its module: '__chrono/file_clock.h'}}
+#include <__chrono/file_clock.h>
diff --git a/libcxx/test/libcxx/diagnostics/detail.headers/chrono/high_resolution_clock.module.verify.cpp b/libcxx/test/libcxx/diagnostics/detail.headers/chrono/high_resolution_clock.module.verify.cpp
new file mode 100644
index 0000000000000..6eda673f1c622
--- /dev/null
+++ b/libcxx/test/libcxx/diagnostics/detail.headers/chrono/high_resolution_clock.module.verify.cpp
@@ -0,0 +1,15 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: modules-build
+
+// WARNING: This test was generated by 'generate_private_header_tests.py'
+// and should not be edited manually.
+
+// expected-error@*:* {{use of private header from outside its module: '__chrono/high_resolution_clock.h'}}
+#include <__chrono/high_resolution_clock.h>
diff --git a/libcxx/test/libcxx/diagnostics/detail.headers/chrono/steady_clock.module.verify.cpp b/libcxx/test/libcxx/diagnostics/detail.headers/chrono/steady_clock.module.verify.cpp
new file mode 100644
index 0000000000000..ef30dd14da9ec
--- /dev/null
+++ b/libcxx/test/libcxx/diagnostics/detail.headers/chrono/steady_clock.module.verify.cpp
@@ -0,0 +1,15 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: modules-build
+
+// WARNING: This test was generated by 'generate_private_header_tests.py'
+// and should not be edited manually.
+
+// expected-error@*:* {{use of private header from outside its module: '__chrono/steady_clock.h'}}
+#include <__chrono/steady_clock.h>
diff --git a/libcxx/test/libcxx/diagnostics/detail.headers/chrono/system_clock.module.verify.cpp b/libcxx/test/libcxx/diagnostics/detail.headers/chrono/system_clock.module.verify.cpp
new file mode 100644
index 0000000000000..7a007d8710bef
--- /dev/null
+++ b/libcxx/test/libcxx/diagnostics/detail.headers/chrono/system_clock.module.verify.cpp
@@ -0,0 +1,15 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: modules-build
+
+// WARNING: This test was generated by 'generate_private_header_tests.py'
+// and should not be edited manually.
+
+// expected-error@*:* {{use of private header from outside its module: '__chrono/system_clock.h'}}
+#include <__chrono/system_clock.h>
diff --git a/libcxx/test/libcxx/diagnostics/detail.headers/chrono/time_point.module.verify.cpp b/libcxx/test/libcxx/diagnostics/detail.headers/chrono/time_point.module.verify.cpp
new file mode 100644
index 0000000000000..fa9de3a5860cc
--- /dev/null
+++ b/libcxx/test/libcxx/diagnostics/detail.headers/chrono/time_point.module.verify.cpp
@@ -0,0 +1,15 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: modules-build
+
+// WARNING: This test was generated by 'generate_private_header_tests.py'
+// and should not be edited manually.
+
+// expected-error@*:* {{use of private header from outside its module: '__chrono/time_point.h'}}
+#include <__chrono/time_point.h>
diff --git a/libcxx/test/std/input.output/filesystems/fs.filesystem.synopsis/file_time_type_resolution.compile.pass.cpp b/libcxx/test/std/input.output/filesystems/fs.filesystem.synopsis/file_time_type_resolution.compile.pass.cpp
index 965e7a4620b87..578addaa107ee 100644
--- a/libcxx/test/std/input.output/filesystems/fs.filesystem.synopsis/file_time_type_resolution.compile.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/fs.filesystem.synopsis/file_time_type_resolution.compile.pass.cpp
@@ -17,6 +17,7 @@
#include "filesystem_include.h"
#include <chrono>
+#include <ratio>
#include <type_traits>
#include "test_macros.h"
diff --git a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
index 3129c9ce13ff6..4ecf6289c058a 100644
--- a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
@@ -27,6 +27,7 @@
#include <cstdio>
#include <cstdlib>
#include <ctime>
+#include <ratio>
#include <type_traits>
#include "test_macros.h"
diff --git a/libcxx/test/std/utilities/time/days.pass.cpp b/libcxx/test/std/utilities/time/days.pass.cpp
index 22104807640db..c4d3bb7550272 100644
--- a/libcxx/test/std/utilities/time/days.pass.cpp
+++ b/libcxx/test/std/utilities/time/days.pass.cpp
@@ -12,8 +12,9 @@
// using days = duration<signed integer type of at least 25 bits, ratio_multiply<ratio<24>, hours::period>>;
#include <chrono>
-#include <type_traits>
#include <limits>
+#include <ratio>
+#include <type_traits>
#include "test_macros.h"
diff --git a/libcxx/test/std/utilities/time/hours.pass.cpp b/libcxx/test/std/utilities/time/hours.pass.cpp
index 1372f9a3108bd..52080d2cd3595 100644
--- a/libcxx/test/std/utilities/time/hours.pass.cpp
+++ b/libcxx/test/std/utilities/time/hours.pass.cpp
@@ -11,8 +11,9 @@
// typedef duration<signed integral type of at least 23 bits, ratio<3600>> hours;
#include <chrono>
-#include <type_traits>
#include <limits>
+#include <ratio>
+#include <type_traits>
#include "test_macros.h"
diff --git a/libcxx/test/std/utilities/time/microseconds.pass.cpp b/libcxx/test/std/utilities/time/microseconds.pass.cpp
index ca21ace5d19c5..0028e665e0213 100644
--- a/libcxx/test/std/utilities/time/microseconds.pass.cpp
+++ b/libcxx/test/std/utilities/time/microseconds.pass.cpp
@@ -11,8 +11,9 @@
// typedef duration<signed integral type of at least 55 bits, micro> microseconds;
#include <chrono>
-#include <type_traits>
#include <limits>
+#include <ratio>
+#include <type_traits>
#include "test_macros.h"
diff --git a/libcxx/test/std/utilities/time/milliseconds.pass.cpp b/libcxx/test/std/utilities/time/milliseconds.pass.cpp
index 231375b5ab1b5..6576a995b5266 100644
--- a/libcxx/test/std/utilities/time/milliseconds.pass.cpp
+++ b/libcxx/test/std/utilities/time/milliseconds.pass.cpp
@@ -11,8 +11,9 @@
// typedef duration<signed integral type of at least 45 bits, milli> milliseconds;
#include <chrono>
-#include <type_traits>
#include <limits>
+#include <ratio>
+#include <type_traits>
#include "test_macros.h"
diff --git a/libcxx/test/std/utilities/time/minutes.pass.cpp b/libcxx/test/std/utilities/time/minutes.pass.cpp
index 14e79f4ab6373..1dee04c0f0f7d 100644
--- a/libcxx/test/std/utilities/time/minutes.pass.cpp
+++ b/libcxx/test/std/utilities/time/minutes.pass.cpp
@@ -11,8 +11,9 @@
// typedef duration<signed integral type of at least 29 bits, ratio< 60>> minutes;
#include <chrono>
-#include <type_traits>
#include <limits>
+#include <ratio>
+#include <type_traits>
#include "test_macros.h"
diff --git a/libcxx/test/std/utilities/time/months.pass.cpp b/libcxx/test/std/utilities/time/months.pass.cpp
index e8db182f4f979..f9c82286bac33 100644
--- a/libcxx/test/std/utilities/time/months.pass.cpp
+++ b/libcxx/test/std/utilities/time/months.pass.cpp
@@ -11,10 +11,10 @@
// using months = duration<signed integer type of at least 20 bits, ratio_divide<years::period, ratio<12>>>;
-
#include <chrono>
-#include <type_traits>
#include <limits>
+#include <ratio>
+#include <type_traits>
#include "test_macros.h"
diff --git a/libcxx/test/std/utilities/time/nanoseconds.pass.cpp b/libcxx/test/std/utilities/time/nanoseconds.pass.cpp
index 29c973223124b..a4a9e7acf7b0e 100644
--- a/libcxx/test/std/utilities/time/nanoseconds.pass.cpp
+++ b/libcxx/test/std/utilities/time/nanoseconds.pass.cpp
@@ -11,8 +11,9 @@
// typedef duration<signed integral type of at least 64 bits, nano> nanoseconds;
#include <chrono>
-#include <type_traits>
#include <limits>
+#include <ratio>
+#include <type_traits>
#include "test_macros.h"
diff --git a/libcxx/test/std/utilities/time/seconds.pass.cpp b/libcxx/test/std/utilities/time/seconds.pass.cpp
index 57fbb1d27e3fe..09affe6a8924f 100644
--- a/libcxx/test/std/utilities/time/seconds.pass.cpp
+++ b/libcxx/test/std/utilities/time/seconds.pass.cpp
@@ -11,8 +11,9 @@
// typedef duration<signed integral type of at least 35 bits > seconds;
#include <chrono>
-#include <type_traits>
#include <limits>
+#include <ratio>
+#include <type_traits>
#include "test_macros.h"
diff --git a/libcxx/test/std/utilities/time/time.clock/time.clock.file/consistency.pass.cpp b/libcxx/test/std/utilities/time/time.clock/time.clock.file/consistency.pass.cpp
index fe7832241b626..cb49c596c56ca 100644
--- a/libcxx/test/std/utilities/time/time.clock/time.clock.file/consistency.pass.cpp
+++ b/libcxx/test/std/utilities/time/time.clock/time.clock.file/consistency.pass.cpp
@@ -19,6 +19,7 @@
// check clock invariants
#include <chrono>
+#include <type_traits>
#include "test_macros.h"
diff --git a/libcxx/test/std/utilities/time/time.clock/time.clock.file/rep_signed.pass.cpp b/libcxx/test/std/utilities/time/time.clock/time.clock.file/rep_signed.pass.cpp
index 09e86c74cca94..ca7e128b0ecd8 100644
--- a/libcxx/test/std/utilities/time/time.clock/time.clock.file/rep_signed.pass.cpp
+++ b/libcxx/test/std/utilities/time/time.clock/time.clock.file/rep_signed.pass.cpp
@@ -16,6 +16,7 @@
#include <chrono>
#include <cassert>
+#include <type_traits>
#include "test_macros.h"
diff --git a/libcxx/test/std/utilities/time/time.clock/time.clock.hires/consistency.pass.cpp b/libcxx/test/std/utilities/time/time.clock/time.clock.hires/consistency.pass.cpp
index 3e83e42e29f75..ad1bce8963074 100644
--- a/libcxx/test/std/utilities/time/time.clock/time.clock.hires/consistency.pass.cpp
+++ b/libcxx/test/std/utilities/time/time.clock/time.clock.hires/consistency.pass.cpp
@@ -17,6 +17,7 @@
// check clock invariants
#include <chrono>
+#include <type_traits>
#include "test_macros.h"
diff --git a/libcxx/test/std/utilities/time/time.clock/time.clock.steady/consistency.pass.cpp b/libcxx/test/std/utilities/time/time.clock/time.clock.steady/consistency.pass.cpp
index a4d812c42e526..5e7ad46c0cb81 100644
--- a/libcxx/test/std/utilities/time/time.clock/time.clock.steady/consistency.pass.cpp
+++ b/libcxx/test/std/utilities/time/time.clock/time.clock.steady/consistency.pass.cpp
@@ -19,6 +19,7 @@
// check clock invariants
#include <chrono>
+#include <type_traits>
#include "test_macros.h"
diff --git a/libcxx/test/std/utilities/time/time.clock/time.clock.system/consistency.pass.cpp b/libcxx/test/std/utilities/time/time.clock/time.clock.system/consistency.pass.cpp
index 4ad2ac2c268ae..124e9fe41bea0 100644
--- a/libcxx/test/std/utilities/time/time.clock/time.clock.system/consistency.pass.cpp
+++ b/libcxx/test/std/utilities/time/time.clock/time.clock.system/consistency.pass.cpp
@@ -17,6 +17,7 @@
// check clock invariants
#include <chrono>
+#include <type_traits>
#include "test_macros.h"
diff --git a/libcxx/test/std/utilities/time/time.duration/default_ratio.pass.cpp b/libcxx/test/std/utilities/time/time.duration/default_ratio.pass.cpp
index d59d59a6bbd3e..05bf8a9d3e343 100644
--- a/libcxx/test/std/utilities/time/time.duration/default_ratio.pass.cpp
+++ b/libcxx/test/std/utilities/time/time.duration/default_ratio.pass.cpp
@@ -16,6 +16,7 @@
// class duration;
#include <chrono>
+#include <ratio>
#include <type_traits>
#include "test_macros.h"
diff --git a/libcxx/test/std/utilities/time/time.duration/time.duration.alg/abs.pass.cpp b/libcxx/test/std/utilities/time/time.duration/time.duration.alg/abs.pass.cpp
index 40cba3ec91539..f95d42b52638e 100644
--- a/libcxx/test/std/utilities/time/time.duration/time.duration.alg/abs.pass.cpp
+++ b/libcxx/test/std/utilities/time/time.duration/time.duration.alg/abs.pass.cpp
@@ -16,8 +16,9 @@
// constexpr duration<Rep, Period> abs(duration<Rep, Period> d)
#include <chrono>
-#include <type_traits>
#include <cassert>
+#include <ratio>
+#include <type_traits>
#include "test_macros.h"
diff --git a/libcxx/test/std/utilities/time/time.duration/time.duration.arithmetic/op_+.pass.cpp b/libcxx/test/std/utilities/time/time.duration/time.duration.arithmetic/op_+.pass.cpp
index a9d136f792ae6..192448a450ebb 100644
--- a/libcxx/test/std/utilities/time/time.duration/time.duration.arithmetic/op_+.pass.cpp
+++ b/libcxx/test/std/utilities/time/time.duration/time.duration.arithmetic/op_+.pass.cpp
@@ -14,6 +14,8 @@
#include <chrono>
#include <cassert>
+#include <ratio>
+#include <type_traits>
#include "test_macros.h"
diff --git a/libcxx/test/std/utilities/time/time.duration/time.duration.arithmetic/op_-.pass.cpp b/libcxx/test/std/utilities/time/time.duration/time.duration.arithmetic/op_-.pass.cpp
index fe065ff5f997c..533547dd12946 100644
--- a/libcxx/test/std/utilities/time/time.duration/time.duration.arithmetic/op_-.pass.cpp
+++ b/libcxx/test/std/utilities/time/time.duration/time.duration.arithmetic/op_-.pass.cpp
@@ -14,6 +14,8 @@
#include <chrono>
#include <cassert>
+#include <ratio>
+#include <type_traits>
#include "test_macros.h"
diff --git a/libcxx/test/std/utilities/time/time.duration/time.duration.cast/duration_cast.pass.cpp b/libcxx/test/std/utilities/time/time.duration/time.duration.cast/duration_cast.pass.cpp
index 4151756764abf..4fee946b449d2 100644
--- a/libcxx/test/std/utilities/time/time.duration/time.duration.cast/duration_cast.pass.cpp
+++ b/libcxx/test/std/utilities/time/time.duration/time.duration.cast/duration_cast.pass.cpp
@@ -16,8 +16,9 @@
// duration_cast(const duration<Rep, Period>& d);
#include <chrono>
-#include <type_traits>
#include <cassert>
+#include <ratio>
+#include <type_traits>
#include "test_macros.h"
diff --git a/libcxx/test/std/utilities/time/time.duration/time.duration.comparisons/op_equal.pass.cpp b/libcxx/test/std/utilities/time/time.duration/time.duration.comparisons/op_equal.pass.cpp
index c27b528017ec9..50cc3a2b1c91f 100644
--- a/libcxx/test/std/utilities/time/time.duration/time.duration.comparisons/op_equal.pass.cpp
+++ b/libcxx/test/std/utilities/time/time.duration/time.duration.comparisons/op_equal.pass.cpp
@@ -22,6 +22,7 @@
#include <chrono>
#include <cassert>
+#include <ratio>
#include "test_macros.h"
diff --git a/libcxx/test/std/utilities/time/time.duration/time.duration.comparisons/op_less.pass.cpp b/libcxx/test/std/utilities/time/time.duration/time.duration.comparisons/op_less.pass.cpp
index de476357650c9..9f05f2855c235 100644
--- a/libcxx/test/std/utilities/time/time.duration/time.duration.comparisons/op_less.pass.cpp
+++ b/libcxx/test/std/utilities/time/time.duration/time.duration.comparisons/op_less.pass.cpp
@@ -32,6 +32,7 @@
#include <chrono>
#include <cassert>
+#include <ratio>
#include "test_macros.h"
diff --git a/libcxx/test/std/utilities/time/time.duration/time.duration.cons/convert_inexact.pass.cpp b/libcxx/test/std/utilities/time/time.duration/time.duration.cons/convert_inexact.pass.cpp
index f72c69c7ef1ab..4a3a069d8e05d 100644
--- a/libcxx/test/std/utilities/time/time.duration/time.duration.cons/convert_inexact.pass.cpp
+++ b/libcxx/test/std/utilities/time/time.duration/time.duration.cons/convert_inexact.pass.cpp
@@ -17,6 +17,7 @@
#include <chrono>
#include <cassert>
+#include <ratio>
#include "test_macros.h"
diff --git a/libcxx/test/std/utilities/time/time.duration/time.duration.cons/convert_int_to_float.pass.cpp b/libcxx/test/std/utilities/time/time.duration/time.duration.cons/convert_int_to_float.pass.cpp
index fb127226a6c45..546c8dd72de7e 100644
--- a/libcxx/test/std/utilities/time/time.duration/time.duration.cons/convert_int_to_float.pass.cpp
+++ b/libcxx/test/std/utilities/time/time.duration/time.duration.cons/convert_int_to_float.pass.cpp
@@ -17,6 +17,7 @@
#include <chrono>
#include <cassert>
+#include <ratio>
#include "test_macros.h"
diff --git a/libcxx/test/std/utilities/time/time.duration/time.duration.cons/convert_overflow.pass.cpp b/libcxx/test/std/utilities/time/time.duration/time.duration.cons/convert_overflow.pass.cpp
index d76018dbd4980..e6a0df62861e2 100644
--- a/libcxx/test/std/utilities/time/time.duration/time.duration.cons/convert_overflow.pass.cpp
+++ b/libcxx/test/std/utilities/time/time.duration/time.duration.cons/convert_overflow.pass.cpp
@@ -17,6 +17,7 @@
#include <chrono>
#include <cassert>
+#include <ratio>
#include "test_macros.h"
diff --git a/libcxx/test/std/utilities/time/time.duration/time.duration.cons/rep.pass.cpp b/libcxx/test/std/utilities/time/time.duration/time.duration.cons/rep.pass.cpp
index d1a808ba15412..92dbc5e9b62ad 100644
--- a/libcxx/test/std/utilities/time/time.duration/time.duration.cons/rep.pass.cpp
+++ b/libcxx/test/std/utilities/time/time.duration/time.duration.cons/rep.pass.cpp
@@ -15,6 +15,7 @@
#include <chrono>
#include <cassert>
+#include <ratio>
#include "test_macros.h"
#include "../../rep.h"
diff --git a/libcxx/test/std/utilities/time/time.duration/time.duration.nonmember/op_+.pass.cpp b/libcxx/test/std/utilities/time/time.duration/time.duration.nonmember/op_+.pass.cpp
index ad381f0056584..269737f541b19 100644
--- a/libcxx/test/std/utilities/time/time.duration/time.duration.nonmember/op_+.pass.cpp
+++ b/libcxx/test/std/utilities/time/time.duration/time.duration.nonmember/op_+.pass.cpp
@@ -16,6 +16,7 @@
#include <chrono>
#include <cassert>
+#include <ratio>
#include "test_macros.h"
diff --git a/libcxx/test/std/utilities/time/time.duration/time.duration.nonmember/op_-.pass.cpp b/libcxx/test/std/utilities/time/time.duration/time.duration.nonmember/op_-.pass.cpp
index 86ced3fbcbd2a..e4e5af036d307 100644
--- a/libcxx/test/std/utilities/time/time.duration/time.duration.nonmember/op_-.pass.cpp
+++ b/libcxx/test/std/utilities/time/time.duration/time.duration.nonmember/op_-.pass.cpp
@@ -17,6 +17,7 @@
#include <chrono>
#include <cassert>
+#include <ratio>
#include "test_macros.h"
diff --git a/libcxx/test/std/utilities/time/time.duration/time.duration.nonmember/op_divide_duration.pass.cpp b/libcxx/test/std/utilities/time/time.duration/time.duration.nonmember/op_divide_duration.pass.cpp
index e4190fe338543..d580f4edf2fe5 100644
--- a/libcxx/test/std/utilities/time/time.duration/time.duration.nonmember/op_divide_duration.pass.cpp
+++ b/libcxx/test/std/utilities/time/time.duration/time.duration.nonmember/op_divide_duration.pass.cpp
@@ -17,6 +17,7 @@
#include <chrono>
#include <cassert>
+#include <ratio>
#include "test_macros.h"
#include "truncate_fp.h"
diff --git a/libcxx/test/std/utilities/time/time.duration/time.duration.nonmember/op_mod_duration.pass.cpp b/libcxx/test/std/utilities/time/time.duration/time.duration.nonmember/op_mod_duration.pass.cpp
index e7007c1fe35aa..8b8b50d940b84 100644
--- a/libcxx/test/std/utilities/time/time.duration/time.duration.nonmember/op_mod_duration.pass.cpp
+++ b/libcxx/test/std/utilities/time/time.duration/time.duration.nonmember/op_mod_duration.pass.cpp
@@ -17,6 +17,7 @@
#include <chrono>
#include <cassert>
+#include <ratio>
#include "test_macros.h"
diff --git a/libcxx/test/std/utilities/time/time.duration/types.pass.cpp b/libcxx/test/std/utilities/time/time.duration/types.pass.cpp
index 30f92863be2d7..0d5ba0c08f180 100644
--- a/libcxx/test/std/utilities/time/time.duration/types.pass.cpp
+++ b/libcxx/test/std/utilities/time/time.duration/types.pass.cpp
@@ -16,6 +16,7 @@
// typedef Period period;
#include <chrono>
+#include <ratio>
#include <type_traits>
#include "test_macros.h"
diff --git a/libcxx/test/std/utilities/time/time.hms/hhmmss.fail.cpp b/libcxx/test/std/utilities/time/time.hms/hhmmss.fail.cpp
index f2e49a4ecce6c..5da162ed57229 100644
--- a/libcxx/test/std/utilities/time/time.hms/hhmmss.fail.cpp
+++ b/libcxx/test/std/utilities/time/time.hms/hhmmss.fail.cpp
@@ -21,10 +21,10 @@ struct A {};
int main(int, char**)
{
- std::chrono::hh_mm_ss<void> h0; // expected-error-re at chrono:* {{static_assert failed {{.*}} "template parameter of hh_mm_ss must be a std::chrono::duration"}}
- std::chrono::hh_mm_ss<int> h1; // expected-error-re at chrono:* {{static_assert failed {{.*}} "template parameter of hh_mm_ss must be a std::chrono::duration"}}
- std::chrono::hh_mm_ss<std::string> h2; // expected-error-re at chrono:* {{static_assert failed {{.*}} "template parameter of hh_mm_ss must be a std::chrono::duration"}}
- std::chrono::hh_mm_ss<A> h3; // expected-error-re at chrono:* {{static_assert failed {{.*}} "template parameter of hh_mm_ss must be a std::chrono::duration"}}
+ std::chrono::hh_mm_ss<void> h0; // expected-error-re@*:* {{static_assert failed {{.*}} "template parameter of hh_mm_ss must be a std::chrono::duration"}}
+ std::chrono::hh_mm_ss<int> h1; // expected-error-re@*:* {{static_assert failed {{.*}} "template parameter of hh_mm_ss must be a std::chrono::duration"}}
+ std::chrono::hh_mm_ss<std::string> h2; // expected-error-re@*:* {{static_assert failed {{.*}} "template parameter of hh_mm_ss must be a std::chrono::duration"}}
+ std::chrono::hh_mm_ss<A> h3; // expected-error-re@*:* {{static_assert failed {{.*}} "template parameter of hh_mm_ss must be a std::chrono::duration"}}
return 0;
}
diff --git a/libcxx/test/std/utilities/time/time.hms/time.12/is_am.pass.cpp b/libcxx/test/std/utilities/time/time.hms/time.12/is_am.pass.cpp
index 6db2a54a8f447..3da5371c21c17 100644
--- a/libcxx/test/std/utilities/time/time.hms/time.12/is_am.pass.cpp
+++ b/libcxx/test/std/utilities/time/time.hms/time.12/is_am.pass.cpp
@@ -13,6 +13,7 @@
#include <chrono>
#include <cassert>
+#include <utility>
#include "test_macros.h"
diff --git a/libcxx/test/std/utilities/time/time.hms/time.12/is_pm.pass.cpp b/libcxx/test/std/utilities/time/time.hms/time.12/is_pm.pass.cpp
index 8cb7e59a81e2d..7ce59dc8a1b17 100644
--- a/libcxx/test/std/utilities/time/time.hms/time.12/is_pm.pass.cpp
+++ b/libcxx/test/std/utilities/time/time.hms/time.12/is_pm.pass.cpp
@@ -13,6 +13,7 @@
#include <chrono>
#include <cassert>
+#include <utility>
#include "test_macros.h"
diff --git a/libcxx/test/std/utilities/time/time.hms/time.12/make12.pass.cpp b/libcxx/test/std/utilities/time/time.hms/time.12/make12.pass.cpp
index 0483c3cae2355..e0000968abd4b 100644
--- a/libcxx/test/std/utilities/time/time.hms/time.12/make12.pass.cpp
+++ b/libcxx/test/std/utilities/time/time.hms/time.12/make12.pass.cpp
@@ -14,6 +14,7 @@
#include <chrono>
#include <cassert>
+#include <utility>
#include "test_macros.h"
diff --git a/libcxx/test/std/utilities/time/time.hms/time.12/make24.pass.cpp b/libcxx/test/std/utilities/time/time.hms/time.12/make24.pass.cpp
index 8323543f1cee2..2509d1cc622d7 100644
--- a/libcxx/test/std/utilities/time/time.hms/time.12/make24.pass.cpp
+++ b/libcxx/test/std/utilities/time/time.hms/time.12/make24.pass.cpp
@@ -17,6 +17,7 @@
#include <chrono>
#include <cassert>
+#include <utility>
#include "test_macros.h"
diff --git a/libcxx/test/std/utilities/time/time.hms/time.hms.members/hours.pass.cpp b/libcxx/test/std/utilities/time/time.hms/time.hms.members/hours.pass.cpp
index 35b285b683523..ce7591c78b5eb 100644
--- a/libcxx/test/std/utilities/time/time.hms/time.hms.members/hours.pass.cpp
+++ b/libcxx/test/std/utilities/time/time.hms/time.hms.members/hours.pass.cpp
@@ -26,6 +26,8 @@
#include <chrono>
#include <cassert>
+#include <ratio>
+#include <utility>
#include "test_macros.h"
diff --git a/libcxx/test/std/utilities/time/time.hms/time.hms.members/is_negative.pass.cpp b/libcxx/test/std/utilities/time/time.hms/time.hms.members/is_negative.pass.cpp
index 94b164d027734..06dee423d2dc7 100644
--- a/libcxx/test/std/utilities/time/time.hms/time.hms.members/is_negative.pass.cpp
+++ b/libcxx/test/std/utilities/time/time.hms/time.hms.members/is_negative.pass.cpp
@@ -15,6 +15,8 @@
#include <chrono>
#include <cassert>
+#include <ratio>
+#include <utility>
#include "test_macros.h"
diff --git a/libcxx/test/std/utilities/time/time.hms/time.hms.members/minutes.pass.cpp b/libcxx/test/std/utilities/time/time.hms/time.hms.members/minutes.pass.cpp
index 3e8d27c4d01b4..570b2727626b7 100644
--- a/libcxx/test/std/utilities/time/time.hms/time.hms.members/minutes.pass.cpp
+++ b/libcxx/test/std/utilities/time/time.hms/time.hms.members/minutes.pass.cpp
@@ -17,6 +17,8 @@
#include <chrono>
#include <cassert>
+#include <ratio>
+#include <utility>
#include "test_macros.h"
diff --git a/libcxx/test/std/utilities/time/time.hms/time.hms.members/precision.pass.cpp b/libcxx/test/std/utilities/time/time.hms/time.hms.members/precision.pass.cpp
index 622495a3a92a2..eb93c038acaf5 100644
--- a/libcxx/test/std/utilities/time/time.hms/time.hms.members/precision.pass.cpp
+++ b/libcxx/test/std/utilities/time/time.hms/time.hms.members/precision.pass.cpp
@@ -20,6 +20,8 @@
#include <chrono>
#include <cassert>
+#include <ratio>
+#include <type_traits>
#include "test_macros.h"
diff --git a/libcxx/test/std/utilities/time/time.hms/time.hms.members/seconds.pass.cpp b/libcxx/test/std/utilities/time/time.hms/time.hms.members/seconds.pass.cpp
index e38eea0d7bfe9..cfe2760b522ac 100644
--- a/libcxx/test/std/utilities/time/time.hms/time.hms.members/seconds.pass.cpp
+++ b/libcxx/test/std/utilities/time/time.hms/time.hms.members/seconds.pass.cpp
@@ -17,6 +17,8 @@
#include <chrono>
#include <cassert>
+#include <ratio>
+#include <utility>
#include "test_macros.h"
diff --git a/libcxx/test/std/utilities/time/time.hms/time.hms.members/subseconds.pass.cpp b/libcxx/test/std/utilities/time/time.hms/time.hms.members/subseconds.pass.cpp
index aaf714778fb28..a0b418a17a8ff 100644
--- a/libcxx/test/std/utilities/time/time.hms/time.hms.members/subseconds.pass.cpp
+++ b/libcxx/test/std/utilities/time/time.hms/time.hms.members/subseconds.pass.cpp
@@ -17,6 +17,8 @@
#include <chrono>
#include <cassert>
+#include <ratio>
+#include <utility>
#include "test_macros.h"
diff --git a/libcxx/test/std/utilities/time/time.hms/time.hms.members/to_duration.pass.cpp b/libcxx/test/std/utilities/time/time.hms/time.hms.members/to_duration.pass.cpp
index 90f476a563482..129dcceb6a0a1 100644
--- a/libcxx/test/std/utilities/time/time.hms/time.hms.members/to_duration.pass.cpp
+++ b/libcxx/test/std/utilities/time/time.hms/time.hms.members/to_duration.pass.cpp
@@ -17,6 +17,8 @@
#include <chrono>
#include <cassert>
+#include <ratio>
+#include <utility>
#include "test_macros.h"
diff --git a/libcxx/test/std/utilities/time/time.hms/time.hms.members/width.pass.cpp b/libcxx/test/std/utilities/time/time.hms/time.hms.members/width.pass.cpp
index 85cc45947e16e..e8a3c1f2bb6c3 100644
--- a/libcxx/test/std/utilities/time/time.hms/time.hms.members/width.pass.cpp
+++ b/libcxx/test/std/utilities/time/time.hms/time.hms.members/width.pass.cpp
@@ -23,6 +23,7 @@
#include <chrono>
#include <cassert>
+#include <ratio>
#include "test_macros.h"
diff --git a/libcxx/test/std/utilities/time/time.point/time.point.cast/time_point_cast.pass.cpp b/libcxx/test/std/utilities/time/time.point/time.point.cast/time_point_cast.pass.cpp
index 90e6ccef666bb..0d82e2db8b7b7 100644
--- a/libcxx/test/std/utilities/time/time.point/time.point.cast/time_point_cast.pass.cpp
+++ b/libcxx/test/std/utilities/time/time.point/time.point.cast/time_point_cast.pass.cpp
@@ -15,8 +15,9 @@
// time_point_cast(const time_point<Clock, Duration>& t);
#include <chrono>
-#include <type_traits>
#include <cassert>
+#include <ratio>
+#include <type_traits>
#include "test_macros.h"
diff --git a/libcxx/test/std/utilities/time/time.point/time.point.cons/default.pass.cpp b/libcxx/test/std/utilities/time/time.point/time.point.cons/default.pass.cpp
index b40113999a573..e4197aa6aec24 100644
--- a/libcxx/test/std/utilities/time/time.point/time.point.cons/default.pass.cpp
+++ b/libcxx/test/std/utilities/time/time.point/time.point.cons/default.pass.cpp
@@ -14,6 +14,7 @@
#include <chrono>
#include <cassert>
+#include <ratio>
#include "test_macros.h"
#include "../../rep.h"
diff --git a/libcxx/test/std/utilities/time/time.point/time.point.nonmember/op_-duration.pass.cpp b/libcxx/test/std/utilities/time/time.point/time.point.nonmember/op_-duration.pass.cpp
index 6fe8769695b1a..80e9d04a769fd 100644
--- a/libcxx/test/std/utilities/time/time.point/time.point.nonmember/op_-duration.pass.cpp
+++ b/libcxx/test/std/utilities/time/time.point/time.point.nonmember/op_-duration.pass.cpp
@@ -16,6 +16,7 @@
#include <chrono>
#include <cassert>
+#include <cstdint>
#include "test_macros.h"
@@ -47,8 +48,8 @@ int main(int, char**)
static_assert(t2.time_since_epoch() == Duration2(2995), "");
}
#endif
- test2739<int32_t>();
- test2739<uint32_t>();
+ test2739<std::int32_t>();
+ test2739<std::uint32_t>();
return 0;
}
diff --git a/libcxx/test/std/utilities/time/time.traits/time.traits.specializations/duration.pass.cpp b/libcxx/test/std/utilities/time/time.traits/time.traits.specializations/duration.pass.cpp
index 93da8b9b300d7..8b1b589866258 100644
--- a/libcxx/test/std/utilities/time/time.traits/time.traits.specializations/duration.pass.cpp
+++ b/libcxx/test/std/utilities/time/time.traits/time.traits.specializations/duration.pass.cpp
@@ -15,6 +15,8 @@
// };
#include <chrono>
+#include <ratio>
+#include <type_traits>
#include "test_macros.h"
diff --git a/libcxx/test/std/utilities/time/time.traits/time.traits.specializations/time_point.pass.cpp b/libcxx/test/std/utilities/time/time.traits/time.traits.specializations/time_point.pass.cpp
index ea20bf856b0af..181c3e0030948 100644
--- a/libcxx/test/std/utilities/time/time.traits/time.traits.specializations/time_point.pass.cpp
+++ b/libcxx/test/std/utilities/time/time.traits/time.traits.specializations/time_point.pass.cpp
@@ -15,6 +15,8 @@
// };
#include <chrono>
+#include <ratio>
+#include <type_traits>
#include "test_macros.h"
diff --git a/libcxx/test/std/utilities/time/weeks.pass.cpp b/libcxx/test/std/utilities/time/weeks.pass.cpp
index 210e01d9dc2dd..6795fd49a51c8 100644
--- a/libcxx/test/std/utilities/time/weeks.pass.cpp
+++ b/libcxx/test/std/utilities/time/weeks.pass.cpp
@@ -12,8 +12,9 @@
// using weeks = duration<signed integer type of at least 22 bits, ratio_multiply<ratio<7>, days::period>>;
#include <chrono>
-#include <type_traits>
#include <limits>
+#include <ratio>
+#include <type_traits>
#include "test_macros.h"
diff --git a/libcxx/test/std/utilities/time/years.pass.cpp b/libcxx/test/std/utilities/time/years.pass.cpp
index c27c1c8a200e6..ab8b61b200099 100644
--- a/libcxx/test/std/utilities/time/years.pass.cpp
+++ b/libcxx/test/std/utilities/time/years.pass.cpp
@@ -12,8 +12,9 @@
// using years = duration<signed integer type of at least 17 bits, ratio_multiply<ratio<146097, 400>, days::period>>
#include <chrono>
-#include <type_traits>
#include <limits>
+#include <ratio>
+#include <type_traits>
#include "test_macros.h"
diff --git a/libcxxabi/src/cxa_guard_impl.h b/libcxxabi/src/cxa_guard_impl.h
index c789bae476217..5a7cbfd5cdb9d 100644
--- a/libcxxabi/src/cxa_guard_impl.h
+++ b/libcxxabi/src/cxa_guard_impl.h
@@ -54,6 +54,7 @@
# endif
#endif
+#include <limits.h>
#include <stdlib.h>
#include <__threading_support>
#ifndef _LIBCXXABI_HAS_NO_THREADS
More information about the libcxx-commits
mailing list