#define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__))
+// No apple compilers support ""d and ""y at this time.
+#if _LIBCPP_CLANG_VER < 800 || defined(__apple_build_version__)
+#define _LIBCPP_HAS_NO_CXX20_CHRONO_LITERALS
+#endif
+
#elif defined(_LIBCPP_COMPILER_GCC)
#define _ALIGNAS(x) __attribute__((__aligned__(x)))
parse(const basic_string<charT, traits, Alloc>& format, Parsable& tp,
basic_string<charT, traits, Alloc>& abbrev, minutes& offset);
+// calendrical constants
inline constexpr last_spec last{}; // C++20
inline constexpr chrono::weekday Sunday{0}; // C++20
inline constexpr chrono::weekday Monday{1}; // C++20
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>
typedef system_clock high_resolution_clock;
#endif
+#if _LIBCPP_STD_VER > 17
+
+struct _LIBCPP_TYPE_VIS last_spec { explicit last_spec() = default; };
+
+
+class _LIBCPP_TYPE_VIS 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 _LIBCPP_TYPE_VIS 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 _LIBCPP_TYPE_VIS 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 _LIBCPP_TYPE_VIS weekday_indexed;
+class _LIBCPP_TYPE_VIS weekday_last;
+
+class _LIBCPP_TYPE_VIS weekday {
+private:
+ unsigned char __wd;
+public:
+ weekday() = default;
+ explicit inline constexpr weekday(unsigned __val) noexcept: __wd(static_cast<unsigned char>(__val)) {}
+// inline constexpr weekday(const sys_days& dp) noexcept;
+// explicit constexpr weekday(const local_days& dp) noexcept;
+ 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;
+ explicit inline constexpr operator unsigned() const noexcept { return __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;
+};
+
+inline constexpr
+bool operator==(const weekday& __lhs, const weekday& __rhs) noexcept
+{ return static_cast<unsigned>(__lhs) == static_cast<unsigned>(__rhs); }
+
+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 static_cast<unsigned>(__lhs) < static_cast<unsigned>(__rhs); }
+
+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>(static_cast<unsigned>(__lhs)) + __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 = static_cast<unsigned>(__lhs) - static_cast<unsigned>(__rhs);
+ 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 _LIBCPP_TYPE_VIS weekday_indexed {
+private:
+ _VSTD::chrono::weekday __wd;
+ unsigned char __idx;
+public:
+ weekday_indexed() = default;
+ inline constexpr weekday_indexed(const _VSTD::chrono::weekday& __wdval, unsigned __idxval) noexcept
+ : __wd{__wdval}, __idx(__idxval) {}
+ inline constexpr _VSTD::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 _LIBCPP_TYPE_VIS weekday_last {
+private:
+ _VSTD::chrono::weekday __wd;
+public:
+ explicit constexpr weekday_last(const _VSTD::chrono::weekday& __val) noexcept
+ : __wd{__val} {}
+ constexpr _VSTD::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 _LIBCPP_TYPE_VIS 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 _LIBCPP_TYPE_VIS 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 _LIBCPP_TYPE_VIS 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 _LIBCPP_TYPE_VIS 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 _LIBCPP_TYPE_VIS 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 _LIBCPP_TYPE_VIS 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} {}
+// inline constexpr year_month_day(const year_month_day_last& __ymdl) noexcept;
+// inline constexpr year_month_day(const sys_days& dp) noexcept;
+// inline explicit constexpr year_month_day(const local_days& dp) noexcept;
+ 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;
+// inline explicit constexpr operator local_days() const noexcept;
+
+// TODO: This is not quite correct; requires the calendar bits to do right
+// d_ is in the range [1d, (y_/m_/last).day()],
+ inline constexpr bool ok() const noexcept { return __y.ok() && __m.ok() && __d.ok(); }
+};
+
+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 _LIBCPP_TYPE_VIS 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;
+
+ constexpr chrono::year year() const noexcept { return __y; }
+ constexpr chrono::month month() const noexcept { return __mdl.month(); }
+ constexpr chrono::month_day_last month_day_last() const noexcept { return __mdl; }
+// constexpr chrono::day day() const noexcept;
+// constexpr operator sys_days() const noexcept;
+// explicit constexpr operator local_days() const noexcept;
+ constexpr bool ok() const noexcept { return __y.ok() && __mdl.ok(); }
+};
+
+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; }
+
+class _LIBCPP_TYPE_VIS 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& dp) noexcept;
+// explicit constexpr year_month_weekday(const local_days& dp) noexcept;
+ 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; }
+
+// constexpr operator sys_days() const noexcept;
+// explicit constexpr operator local_days() const noexcept;
+ inline constexpr bool ok() const noexcept
+ {
+ if (!__y.ok() || !__m.ok() || !__wdi.ok()) return false;
+ // TODO: make sure it's a valid date
+ return true;
+ }
+};
+
+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 _LIBCPP_TYPE_VIS 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; }
+// constexpr operator sys_days() const noexcept;
+// explicit constexpr operator local_days() const noexcept;
+ inline constexpr bool ok() const noexcept { return __y.ok() && __m.ok() && __wdl.ok(); }
+};
+
+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; }
+
+#endif // _LIBCPP_STD_VER > 17
} // chrono
#if _LIBCPP_STD_VER > 11
return chrono::duration<long double, nano> (__ns);
}
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CXX20_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));
+ }
+#endif
}}
namespace chrono { // hoist the literals into namespace std::chrono
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+
+// using days = duration<signed integer type of at least 25 bits, ratio_multiply<ratio<24>, hours::period>>;
+
+#include <chrono>
+#include <type_traits>
+#include <limits>
+
+int main()
+{
+ typedef std::chrono::days D;
+ typedef D::rep Rep;
+ typedef D::period Period;
+ static_assert(std::is_signed<Rep>::value, "");
+ static_assert(std::is_integral<Rep>::value, "");
+ static_assert(std::numeric_limits<Rep>::digits >= 25, "");
+ static_assert(std::is_same_v<Period, std::ratio_multiply<std::ratio<24>, std::chrono::hours::period>>, "");
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+
+// using months = duration<signed integer type of at least 20 bits, ratio_divide<years::period, ratio<12>>>;
+
+
+#include <chrono>
+#include <type_traits>
+#include <limits>
+
+int main()
+{
+ typedef std::chrono::months D;
+ typedef D::rep Rep;
+ typedef D::period Period;
+ static_assert(std::is_signed<Rep>::value, "");
+ static_assert(std::is_integral<Rep>::value, "");
+ static_assert(std::numeric_limits<Rep>::digits >= 20, "");
+ static_assert(std::is_same_v<Period, std::ratio_divide<std::chrono::years::period, std::ratio<12>>>, "");
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+
+// Assumption: minValue < maxValue
+// Assumption: minValue <= rhs <= maxValue
+// Assumption: minValue <= lhs <= maxValue
+// Assumption: minValue >= 0
+template <typename T, T minValue, T maxValue>
+T euclidian_addition(T rhs, T lhs)
+{
+ const T modulus = maxValue - minValue + 1;
+ T ret = rhs + lhs;
+ if (ret > maxValue)
+ ret -= modulus;
+ return ret;
+}
+
+// Assumption: minValue < maxValue
+// Assumption: minValue <= rhs <= maxValue
+// Assumption: minValue <= lhs <= maxValue
+// Assumption: minValue >= 0
+template <typename T, T minValue, T maxValue>
+T euclidian_subtraction(T lhs, T rhs)
+{
+ const T modulus = maxValue - minValue + 1;
+ T ret = lhs - rhs;
+ if (ret < minValue)
+ ret += modulus;
+ if (ret > maxValue) // this can happen if T is unsigned
+ ret += modulus;
+ return ret;
+}
+
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class day;
+
+// day() = default;
+// explicit constexpr day(unsigned d) noexcept;
+// explicit constexpr operator unsigned() const noexcept;
+
+// Effects: Constructs an object of type day by initializing d_ with d.
+// The value held is unspecified if d is not in the range [0, 255].
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+ using day = std::chrono::day;
+
+ ASSERT_NOEXCEPT(day{});
+ ASSERT_NOEXCEPT(day(0U));
+ ASSERT_NOEXCEPT(static_cast<unsigned>(day(0U)));
+
+ constexpr day d0{};
+ static_assert(static_cast<unsigned>(d0) == 0, "");
+
+ constexpr day d1{1};
+ static_assert(static_cast<unsigned>(d1) == 1, "");
+
+ for (unsigned i = 0; i <= 255; ++i)
+ {
+ day day(i);
+ assert(static_cast<unsigned>(day) == i);
+ }
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class day;
+
+// constexpr day& operator--() noexcept;
+// constexpr day operator--(int) noexcept;
+
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+template <typename D>
+constexpr bool testConstexpr()
+{
+ D d1{10};
+ if (static_cast<unsigned>(--d1) != 9) return false;
+ if (static_cast<unsigned>(d1--) != 9) return false;
+ if (static_cast<unsigned>(d1) != 8) return false;
+ return true;
+}
+
+int main()
+{
+ using day = std::chrono::day;
+ ASSERT_NOEXCEPT(--(std::declval<day&>()) );
+ ASSERT_NOEXCEPT( (std::declval<day&>())--);
+
+ ASSERT_SAME_TYPE(day , decltype( std::declval<day&>()--));
+ ASSERT_SAME_TYPE(day&, decltype(--std::declval<day&>() ));
+
+ static_assert(testConstexpr<day>(), "");
+
+ for (unsigned i = 10; i <= 20; ++i)
+ {
+ day day(i);
+ assert(static_cast<unsigned>(--day) == i - 1);
+ assert(static_cast<unsigned>(day--) == i - 1);
+ assert(static_cast<unsigned>(day) == i - 2);
+ }
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class day;
+
+// constexpr day& operator++() noexcept;
+// constexpr day operator++(int) noexcept;
+
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+template <typename D>
+constexpr bool testConstexpr()
+{
+ D d1{1};
+ if (static_cast<unsigned>(++d1) != 2) return false;
+ if (static_cast<unsigned>(d1++) != 2) return false;
+ if (static_cast<unsigned>(d1) != 3) return false;
+ return true;
+}
+
+int main()
+{
+ using day = std::chrono::day;
+ ASSERT_NOEXCEPT(++(std::declval<day&>()) );
+ ASSERT_NOEXCEPT( (std::declval<day&>())++);
+
+ ASSERT_SAME_TYPE(day , decltype( std::declval<day&>()++));
+ ASSERT_SAME_TYPE(day&, decltype(++std::declval<day&>() ));
+
+ static_assert(testConstexpr<day>(), "");
+
+ for (unsigned i = 10; i <= 20; ++i)
+ {
+ day day(i);
+ assert(static_cast<unsigned>(++day) == i + 1);
+ assert(static_cast<unsigned>(day++) == i + 1);
+ assert(static_cast<unsigned>(day) == i + 2);
+ }
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class day;
+
+// constexpr bool ok() const noexcept;
+// Returns: 1 <= d_ && d_ <= 31
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+ using day = std::chrono::day;
+ ASSERT_NOEXCEPT( std::declval<const day>().ok());
+ ASSERT_SAME_TYPE(bool, decltype(std::declval<const day>().ok()));
+
+ static_assert(!day{0}.ok(), "");
+ static_assert( day{1}.ok(), "");
+
+ assert(!day{0}.ok());
+ for (unsigned i = 1; i <= 31; ++i)
+ assert(day{i}.ok());
+ for (unsigned i = 32; i <= 255; ++i)
+ assert(!day{i}.ok());
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class day;
+
+// constexpr day& operator+=(const days& d) noexcept;
+// constexpr day& operator-=(const days& d) noexcept;
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+template <typename D, typename Ds>
+constexpr bool testConstexpr()
+{
+ D d1{1};
+ if (static_cast<unsigned>(d1 += Ds{ 1}) != 2) return false;
+ if (static_cast<unsigned>(d1 += Ds{ 2}) != 4) return false;
+ if (static_cast<unsigned>(d1 += Ds{22}) != 26) return false;
+ if (static_cast<unsigned>(d1 -= Ds{ 1}) != 25) return false;
+ if (static_cast<unsigned>(d1 -= Ds{ 2}) != 23) return false;
+ if (static_cast<unsigned>(d1 -= Ds{22}) != 1) return false;
+ return true;
+}
+
+int main()
+{
+ using day = std::chrono::day;
+ using days = std::chrono::days;
+
+ ASSERT_NOEXCEPT(std::declval<day&>() += std::declval<days>());
+ ASSERT_NOEXCEPT(std::declval<day&>() -= std::declval<days>());
+
+ ASSERT_SAME_TYPE(day&, decltype(std::declval<day&>() += std::declval<days>()));
+ ASSERT_SAME_TYPE(day&, decltype(std::declval<day&>() -= std::declval<days>()));
+
+ static_assert(testConstexpr<day, days>(), "");
+
+ for (unsigned i = 0; i <= 10; ++i)
+ {
+ day day(i);
+ assert(static_cast<unsigned>(day += days{22}) == i + 22);
+ assert(static_cast<unsigned>(day) == i + 22);
+ assert(static_cast<unsigned>(day -= days{12}) == i + 10);
+ assert(static_cast<unsigned>(day) == i + 10);
+ }
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class day;
+
+// constexpr bool operator==(const day& x, const day& y) noexcept;
+// Returns: unsigned{x} == unsigned{y}.
+// constexpr bool operator<(const day& x, const day& y) noexcept;
+// Returns: unsigned{x} < unsigned{y}.
+
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+#include "test_comparisons.h"
+
+int main()
+{
+ using day = std::chrono::day;
+
+ AssertComparisons6AreNoexcept<day>();
+ AssertComparisons6ReturnBool<day>();
+
+ static_assert(testComparisons6Values<day>(0U, 0U), "");
+ static_assert(testComparisons6Values<day>(0U, 1U), "");
+
+// Some 'ok' values as well
+ static_assert(testComparisons6Values<day>( 5U, 5U), "");
+ static_assert(testComparisons6Values<day>( 5U, 10U), "");
+
+ for (unsigned i = 1; i < 10; ++i)
+ for (unsigned j = 1; j < 10; ++j)
+ assert(testComparisons6Values<day>(i, j));
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+// UNSUPPORTED: clang-5, clang-6
+// UNSUPPORTED: apple-clang-6, apple-clang-7, apple-clang-8, apple-clang-9
+
+// <chrono>
+// class day;
+
+// constexpr day operator""d(unsigned long long d) noexcept;
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+ using day = std::chrono::day;
+ day d1 = 4d; // expected-error-re {{no matching literal operator for call to 'operator""d' {{.*}}}}
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+// UNSUPPORTED: clang-5, clang-6
+// UNSUPPORTED: apple-clang-6, apple-clang-7, apple-clang-8, apple-clang-9
+
+// <chrono>
+// class day;
+
+// constexpr day operator""d(unsigned long long d) noexcept;
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+ {
+ using namespace std::chrono;
+ ASSERT_NOEXCEPT( 4d);
+ ASSERT_SAME_TYPE(day, decltype(4d));
+
+ static_assert( 7d == day(7), "");
+ day d1 = 4d;
+ assert (d1 == day(4));
+}
+
+ {
+ using namespace std::literals;
+ ASSERT_NOEXCEPT( 4d);
+ ASSERT_SAME_TYPE(std::chrono::day, decltype(4d));
+
+ static_assert( 7d == std::chrono::day(7), "");
+
+ std::chrono::day d1 = 4d;
+ assert (d1 == std::chrono::day(4));
+ }
+
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class day;
+
+// constexpr day operator-(const day& x, const days& y) noexcept;
+// Returns: x + -y.
+//
+// constexpr days operator-(const day& x, const day& y) noexcept;
+// Returns: days{int(unsigned{x}) - int(unsigned{y}).
+
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+template <typename D, typename Ds>
+constexpr bool testConstexpr()
+{
+ D d{23};
+ Ds offset{6};
+ if (d - offset != D{17}) return false;
+ if (d - D{17} != offset) return false;
+ return true;
+}
+
+int main()
+{
+ using day = std::chrono::day;
+ using days = std::chrono::days;
+
+ ASSERT_NOEXCEPT(std::declval<day>() - std::declval<days>());
+ ASSERT_NOEXCEPT(std::declval<day>() - std::declval<day>());
+
+ ASSERT_SAME_TYPE(day, decltype(std::declval<day>() - std::declval<days>()));
+ ASSERT_SAME_TYPE(days, decltype(std::declval<day>() - std::declval<day>()));
+
+ static_assert(testConstexpr<day, days>(), "");
+
+ day dy{12};
+ for (unsigned i = 0; i <= 10; ++i)
+ {
+ day d1 = dy - days{i};
+ days off = dy - day {i};
+ assert(static_cast<unsigned>(d1) == 12 - i);
+ assert(off.count() == static_cast<int>(12 - i)); // days is signed
+ }
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class day;
+
+// constexpr day operator+(const day& x, const days& y) noexcept;
+// Returns: day(unsigned{x} + y.count()).
+//
+// constexpr day operator+(const days& x, const day& y) noexcept;
+// Returns: y + x.
+
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+template <typename D, typename Ds>
+constexpr bool testConstexpr()
+{
+ D d{1};
+ Ds offset{23};
+ if (d + offset != D{24}) return false;
+ if (offset + d != D{24}) return false;
+ return true;
+}
+
+int main()
+{
+ using day = std::chrono::day;
+ using days = std::chrono::days;
+
+ ASSERT_NOEXCEPT(std::declval<day>() + std::declval<days>());
+ ASSERT_NOEXCEPT(std::declval<days>() + std::declval<day>());
+
+ ASSERT_SAME_TYPE(day, decltype(std::declval<day>() + std::declval<days>()));
+ ASSERT_SAME_TYPE(day, decltype(std::declval<days>() + std::declval<day>()));
+
+ static_assert(testConstexpr<day, days>(), "");
+
+ day dy{12};
+ for (unsigned i = 0; i <= 10; ++i)
+ {
+ day d1 = dy + days{i};
+ day d2 = days{i} + dy;
+ assert(d1 == d2);
+ assert(static_cast<unsigned>(d1) == i + 12);
+ assert(static_cast<unsigned>(d2) == i + 12);
+ }
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+// XFAIL: *
+
+// <chrono>
+// class day;
+
+// template<class charT, class traits>
+// basic_ostream<charT, traits>&
+// operator<<(basic_ostream<charT, traits>& os, const day& d);
+//
+// Effects: Inserts format(fmt, d) where fmt is "%d" widened to charT.
+// If !d.ok(), appends with " is not a valid day".
+//
+// template<class charT, class traits>
+// basic_ostream<charT, traits>&
+// to_stream(basic_ostream<charT, traits>& os, const charT* fmt, const day& d);
+//
+// Effects: Streams d into os using the format specified by the NTCTS fmt.
+// fmt encoding follows the rules specified in 25.11.
+//
+// template<class charT, class traits, class Alloc = allocator<charT>>
+// basic_istream<charT, traits>&
+// from_stream(basic_istream<charT, traits>& is, const charT* fmt,
+// day& d, basic_string<charT, traits, Alloc>* abbrev = nullptr,
+// minutes* offset = nullptr);
+//
+// Effects: Attempts to parse the input stream is into the day d using the format flags
+// given in the NTCTS fmt as specified in 25.12.
+// If the parse fails to decode a valid day, is.setstate(ios_base::failbit)
+// shall be called and d shall not be modified.
+// If %Z is used and successfully parsed, that value will be assigned to *abbrev
+// if abbrev is non-null. If %z (or a modified variant) is used and
+// successfully parsed, that value will be assigned to *offset if offset is non-null.
+//
+
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+#include <iostream>
+
+#include "test_macros.h"
+
+int main()
+{
+ using day = std::chrono::day;
+ std::cout << day{1};
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class day;
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+ using day = std::chrono::day;
+
+ static_assert(std::is_trivially_copyable_v<day>, "");
+ static_assert(std::is_standard_layout_v<day>, "");
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+
+// struct last_spec {
+// explicit last_spec() = default;
+// };
+//
+// inline constexpr last_spec last{};
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+ using last_spec = std::chrono::last_spec;
+
+ ASSERT_SAME_TYPE(const last_spec, decltype(std::chrono::last));
+
+ static_assert(std::is_trivially_copyable_v<last_spec>, "");
+ static_assert(std::is_standard_layout_v<last_spec>, "");
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class month_day;
+
+// month_day() = default;
+// constexpr month_day(const chrono::month& m, const chrono::day& d) noexcept;
+//
+// Effects: Constructs an object of type month_day by initializing m_ with m, and d_ with d.
+//
+// constexpr chrono::month month() const noexcept;
+// constexpr chrono::day day() const noexcept;
+// constexpr bool ok() const noexcept;
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+ using day = std::chrono::day;
+ using month = std::chrono::month;
+ using month_day = std::chrono::month_day;
+
+ ASSERT_NOEXCEPT(month_day{});
+ ASSERT_NOEXCEPT(month_day{month{1}, day{1}});
+
+ constexpr month_day md0{};
+ static_assert( md0.month() == month{}, "");
+ static_assert( md0.day() == day{}, "");
+ static_assert(!md0.ok(), "");
+
+ constexpr month_day md1{std::chrono::January, day{4}};
+ static_assert( md1.month() == std::chrono::January, "");
+ static_assert( md1.day() == day{4}, "");
+ static_assert( md1.ok(), "");
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class month_day;
+
+// constexpr chrono::day day() const noexcept;
+// Returns: d_
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+ using day = std::chrono::day;
+ using month = std::chrono::month;
+ using month_day = std::chrono::month_day;
+
+ ASSERT_NOEXCEPT( std::declval<const month_day>().day());
+ ASSERT_SAME_TYPE(day, decltype(std::declval<const month_day>().day()));
+
+ static_assert( month_day{}.day() == day{}, "");
+
+ for (unsigned i = 1; i <= 50; ++i)
+ {
+ month_day md(std::chrono::March, day{i});
+ assert( static_cast<unsigned>(md.day()) == i);
+ }
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class month_day;
+
+// constexpr chrono::month month() const noexcept;
+// Returns: wd_
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+ using day = std::chrono::day;
+ using month = std::chrono::month;
+ using month_day = std::chrono::month_day;
+
+ ASSERT_NOEXCEPT( std::declval<const month_day>().month());
+ ASSERT_SAME_TYPE(month, decltype(std::declval<const month_day>().month()));
+
+ static_assert( month_day{}.month() == month{}, "");
+
+ for (unsigned i = 1; i <= 50; ++i)
+ {
+ month_day md(month{i}, day{1});
+ assert( static_cast<unsigned>(md.month()) == i);
+ }
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class month_day;
+
+// constexpr bool ok() const noexcept;
+// Returns: true if m_.ok() is true, 1d <= d_, and d_ is less than or equal to the
+// number of days in month m_; otherwise returns false.
+// When m_ == February, the number of days is considered to be 29.
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+ using day = std::chrono::day;
+ using month = std::chrono::month;
+ using month_day = std::chrono::month_day;
+
+ ASSERT_NOEXCEPT( std::declval<const month_day>().ok());
+ ASSERT_SAME_TYPE(bool, decltype(std::declval<const month_day>().ok()));
+
+ static_assert(!month_day{}.ok(), "");
+ static_assert( month_day{std::chrono::May, day{2}}.ok(), "");
+
+ assert(!(month_day(std::chrono::April, day{0}).ok()));
+
+ assert( (month_day{std::chrono::March, day{1}}.ok()));
+ for (unsigned i = 1; i <= 12; ++i)
+ {
+ const bool is31 = i == 1 || i == 3 || i == 5 || i == 7 || i == 8 || i == 10 || i == 12;
+ assert(!(month_day{month{i}, day{ 0}}.ok()));
+ assert( (month_day{month{i}, day{ 1}}.ok()));
+ assert( (month_day{month{i}, day{10}}.ok()));
+ assert( (month_day{month{i}, day{29}}.ok()));
+ assert( (month_day{month{i}, day{30}}.ok()) == (i != 2));
+ assert( (month_day{month{i}, day{31}}.ok()) == is31);
+ assert(!(month_day{month{i}, day{32}}.ok()));
+ }
+
+// If the month is not ok, all the days are bad
+ for (unsigned i = 1; i <= 35; ++i)
+ assert(!(month_day{month{13}, day{i}}.ok()));
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class month_day;
+
+// constexpr bool operator==(const month_day& x, const month_day& y) noexcept;
+// Returns: x.month() == y.month() && x.day() == y.day().
+//
+// constexpr bool operator< (const month_day& x, const month_day& y) noexcept;
+// Returns:
+// If x.month() < y.month() returns true.
+// Otherwise, if x.month() > y.month() returns false.
+// Otherwise, returns x.day() < y.day().
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+#include "test_comparisons.h"
+
+int main()
+{
+ using day = std::chrono::day;
+ using month = std::chrono::month;
+ using month_day = std::chrono::month_day;
+
+ AssertComparisons6AreNoexcept<month_day>();
+ AssertComparisons6ReturnBool<month_day>();
+
+ static_assert( testComparisons6(
+ month_day{std::chrono::January, day{1}},
+ month_day{std::chrono::January, day{1}},
+ true, false), "");
+
+ static_assert( testComparisons6(
+ month_day{std::chrono::January, day{1}},
+ month_day{std::chrono::January, day{2}},
+ false, true), "");
+
+ static_assert( testComparisons6(
+ month_day{std::chrono::January, day{1}},
+ month_day{std::chrono::February, day{1}},
+ false, true), "");
+
+// same day, different months
+ for (unsigned i = 1; i < 12; ++i)
+ for (unsigned j = 1; j < 12; ++j)
+ assert((testComparisons6(
+ month_day{month{i}, day{1}},
+ month_day{month{j}, day{1}},
+ i == j, i < j )));
+
+// same month, different days
+ for (unsigned i = 1; i < 31; ++i)
+ for (unsigned j = 1; j < 31; ++j)
+ assert((testComparisons6(
+ month_day{month{2}, day{i}},
+ month_day{month{2}, day{j}},
+ i == j, i < j )));
+
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+// XFAIL: *
+
+// <chrono>
+// class month_day;
+
+// template<class charT, class traits>
+// basic_ostream<charT, traits>&
+// operator<<(basic_ostream<charT, traits>& os, const month_day& md);
+//
+// Returns: os << md.month() << '/' << md.day().
+//
+// template<class charT, class traits>
+// basic_ostream<charT, traits>&
+// to_stream(basic_ostream<charT, traits>& os, const charT* fmt, const month_day& md);
+//
+// Effects: Streams md into os using the format specified by the NTCTS fmt.
+// fmt encoding follows the rules specified in 25.11.
+
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+#include <iostream>
+#include "test_macros.h"
+
+int main()
+{
+ using month_day = std::chrono::month_day;
+ using month = std::chrono::month;
+ using day = std::chrono::day;
+ std::cout << month_day{month{1}, day{1}};
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class month_day;
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+ using month_day = std::chrono::month_day;
+
+ static_assert(std::is_trivially_copyable_v<month_day>, "");
+ static_assert(std::is_standard_layout_v<month_day>, "");
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class month_day_last;
+
+// constexpr bool operator==(const month_day& x, const month_day& y) noexcept;
+// Returns: x.month() == y.month()
+//
+// constexpr bool operator< (const month_day& x, const month_day& y) noexcept;
+// Returns: x.month() < y.month()
+
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+#include "test_comparisons.h"
+
+int main()
+{
+ using month = std::chrono::month;
+ using month_day_last = std::chrono::month_day_last;
+
+ AssertComparisons6AreNoexcept<month_day_last>();
+ AssertComparisons6ReturnBool<month_day_last>();
+
+ static_assert( testComparisons6Values<month_day_last>(month{1}, month{1}), "");
+ static_assert( testComparisons6Values<month_day_last>(month{1}, month{2}), "");
+
+// same day, different months
+ for (unsigned i = 1; i < 12; ++i)
+ for (unsigned j = 1; j < 12; ++j)
+ assert((testComparisons6Values<month_day_last>(month{i}, month{j})));
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class month_day_last;
+
+// constexpr month_day_last(const chrono::month& m) noexcept;
+//
+// Effects: Constructs an object of type month_day_last by initializing m_ with m
+//
+// constexpr chrono::month month() const noexcept;
+// constexpr bool ok() const noexcept;
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+ using month = std::chrono::month;
+ using month_day_last = std::chrono::month_day_last;
+
+ ASSERT_NOEXCEPT(month_day_last{month{1}});
+
+ constexpr month_day_last md0{month{}};
+ static_assert( md0.month() == month{}, "");
+ static_assert(!md0.ok(), "");
+
+ constexpr month_day_last md1{std::chrono::January};
+ static_assert( md1.month() == std::chrono::January, "");
+ static_assert( md1.ok(), "");
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class month_day_last;
+
+// constexpr chrono::month month() const noexcept;
+// Returns: m_
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+ using month = std::chrono::month;
+ using month_day_last = std::chrono::month_day_last;
+
+ ASSERT_NOEXCEPT( std::declval<const month_day_last>().month());
+ ASSERT_SAME_TYPE(month, decltype(std::declval<const month_day_last>().month()));
+
+ static_assert( month_day_last{month{}}.month() == month{}, "");
+
+ for (unsigned i = 1; i <= 50; ++i)
+ {
+ month_day_last mdl(month{i});
+ assert( static_cast<unsigned>(mdl.month()) == i);
+ }
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class month_day_last;
+
+// constexpr bool ok() const noexcept;
+// Returns: m_.ok()
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+ using month = std::chrono::month;
+ using month_day_last = std::chrono::month_day_last;
+
+ ASSERT_NOEXCEPT( std::declval<const month_day_last>().ok());
+ ASSERT_SAME_TYPE(bool, decltype(std::declval<const month_day_last>().ok()));
+
+ static_assert(!month_day_last{month{}}.ok(), "");
+ static_assert( month_day_last{std::chrono::May}.ok(), "");
+
+ for (unsigned i = 1; i <= 12; ++i)
+ {
+ month_day_last mdl{month{i}};
+ assert( mdl.ok());
+ }
+
+// If the month is not ok, all the days are bad
+ for (unsigned i = 13; i <= 50; ++i)
+ {
+ month_day_last mdl{month{i}};
+ assert(!mdl.ok());
+ }
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+// XFAIL: *
+
+// <chrono>
+// class month_day_last;
+//
+// template<class charT, class traits>
+// basic_ostream<charT, traits>&
+// operator<<(basic_ostream<charT, traits>& os, const month_day_last& mdl);
+//
+// Returns: os << mdl.month() << "/last".
+
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+#include <iostream>
+
+#include "test_macros.h"
+
+int main()
+{
+ using month_day_last = std::chrono::month_day_last;
+ using month = std::chrono::month;
+ std::cout << month_day_last{month{1}};
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+
+// class month_day_last;
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+ using month_day_last = std::chrono::month_day_last;
+
+ static_assert(std::is_trivially_copyable_v<month_day_last>, "");
+ static_assert(std::is_standard_layout_v<month_day_last>, "");
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class month;
+
+// month() = default;
+// explicit constexpr month(int m) noexcept;
+// explicit constexpr operator int() const noexcept;
+
+// Effects: Constructs an object of type month by initializing m_ with m.
+// The value held is unspecified if d is not in the range [0, 255].
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+ using month = std::chrono::month;
+
+ ASSERT_NOEXCEPT(month{});
+ ASSERT_NOEXCEPT(month(1));
+ ASSERT_NOEXCEPT(static_cast<unsigned>(month(1)));
+
+ constexpr month m0{};
+ static_assert(static_cast<unsigned>(m0) == 0, "");
+
+ constexpr month m1{1};
+ static_assert(static_cast<unsigned>(m1) == 1, "");
+
+ for (unsigned i = 0; i <= 255; ++i)
+ {
+ month m(i);
+ assert(static_cast<unsigned>(m) == i);
+ }
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class month;
+
+// constexpr month& operator--() noexcept;
+// constexpr month operator--(int) noexcept;
+
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+template <typename M>
+constexpr bool testConstexpr()
+{
+ M m1{10};
+ if (static_cast<unsigned>(--m1) != 9) return false;
+ if (static_cast<unsigned>(m1--) != 9) return false;
+ if (static_cast<unsigned>(m1) != 8) return false;
+ return true;
+}
+
+int main()
+{
+ using month = std::chrono::month;
+
+ ASSERT_NOEXCEPT(--(std::declval<month&>()) );
+ ASSERT_NOEXCEPT( (std::declval<month&>())--);
+
+ ASSERT_SAME_TYPE(month , decltype( std::declval<month&>()--));
+ ASSERT_SAME_TYPE(month&, decltype(--std::declval<month&>() ));
+
+ static_assert(testConstexpr<month>(), "");
+
+ for (unsigned i = 10; i <= 20; ++i)
+ {
+ month month(i);
+ assert(static_cast<unsigned>(--month) == i - 1);
+ assert(static_cast<unsigned>(month--) == i - 1);
+ assert(static_cast<unsigned>(month) == i - 2);
+ }
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class month;
+
+// constexpr month& operator++() noexcept;
+// constexpr month operator++(int) noexcept;
+
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+template <typename M>
+constexpr bool testConstexpr()
+{
+ M m1{1};
+ if (static_cast<unsigned>(++m1) != 2) return false;
+ if (static_cast<unsigned>(m1++) != 2) return false;
+ if (static_cast<unsigned>(m1) != 3) return false;
+ return true;
+}
+
+int main()
+{
+ using month = std::chrono::month;
+ ASSERT_NOEXCEPT(++(std::declval<month&>()) );
+ ASSERT_NOEXCEPT( (std::declval<month&>())++);
+
+ ASSERT_SAME_TYPE(month , decltype( std::declval<month&>()++));
+ ASSERT_SAME_TYPE(month&, decltype(++std::declval<month&>() ));
+
+ static_assert(testConstexpr<month>(), "");
+
+ for (unsigned i = 0; i <= 10; ++i)
+ {
+ month month(i);
+ assert(static_cast<unsigned>(++month) == i + 1);
+ assert(static_cast<unsigned>(month++) == i + 1);
+ assert(static_cast<unsigned>(month) == i + 2);
+ }
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class month;
+
+// constexpr bool ok() const noexcept;
+// Returns: 1 <= d_ && d_ <= 12
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+ using month = std::chrono::month;
+
+ ASSERT_NOEXCEPT( std::declval<const month>().ok());
+ ASSERT_SAME_TYPE(bool, decltype(std::declval<const month>().ok()));
+
+ static_assert(!month{0}.ok(), "");
+ static_assert( month{1}.ok(), "");
+
+ assert(!month{0}.ok());
+ for (unsigned i = 1; i <= 12; ++i)
+ assert(month{i}.ok());
+ for (unsigned i = 13; i <= 255; ++i)
+ assert(!month{i}.ok());
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class month;
+
+// constexpr month& operator+=(const month& d) noexcept;
+// constexpr month& operator-=(const month& d) noexcept;
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+template <typename M, typename Ms>
+constexpr bool testConstexpr()
+{
+ M m1{1};
+ if (static_cast<unsigned>(m1 += Ms{ 1}) != 2) return false;
+ if (static_cast<unsigned>(m1 += Ms{ 2}) != 4) return false;
+ if (static_cast<unsigned>(m1 += Ms{ 8}) != 12) return false;
+ if (static_cast<unsigned>(m1 -= Ms{ 1}) != 11) return false;
+ if (static_cast<unsigned>(m1 -= Ms{ 2}) != 9) return false;
+ if (static_cast<unsigned>(m1 -= Ms{ 8}) != 1) return false;
+ return true;
+}
+
+int main()
+{
+ using month = std::chrono::month;
+ using months = std::chrono::months;
+
+ ASSERT_NOEXCEPT(std::declval<month&>() += std::declval<months&>());
+ ASSERT_NOEXCEPT(std::declval<month&>() -= std::declval<months&>());
+ ASSERT_SAME_TYPE(month&, decltype(std::declval<month&>() += std::declval<months&>()));
+ ASSERT_SAME_TYPE(month&, decltype(std::declval<month&>() -= std::declval<months&>()));
+
+ static_assert(testConstexpr<month, months>(), "");
+
+ for (unsigned i = 1; i <= 10; ++i)
+ {
+ month month(i);
+ int exp = i + 10;
+ while (exp > 12)
+ exp -= 12;
+ assert(static_cast<unsigned>(month += months{10}) == static_cast<unsigned>(exp));
+ assert(static_cast<unsigned>(month) == static_cast<unsigned>(exp));
+ }
+
+ for (unsigned i = 1; i <= 10; ++i)
+ {
+ month month(i);
+ int exp = i - 9;
+ while (exp < 1)
+ exp += 12;
+ assert(static_cast<unsigned>(month -= months{ 9}) == static_cast<unsigned>(exp));
+ assert(static_cast<unsigned>(month) == static_cast<unsigned>(exp));
+ }
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class month;
+
+// constexpr bool operator==(const month& x, const month& y) noexcept;
+// constexpr bool operator!=(const month& x, const month& y) noexcept;
+// constexpr bool operator< (const month& x, const month& y) noexcept;
+// constexpr bool operator> (const month& x, const month& y) noexcept;
+// constexpr bool operator<=(const month& x, const month& y) noexcept;
+// constexpr bool operator>=(const month& x, const month& y) noexcept;
+
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+#include "test_comparisons.h"
+
+
+int main()
+{
+ using month = std::chrono::month;
+
+ AssertComparisons6AreNoexcept<month>();
+ AssertComparisons6ReturnBool<month>();
+
+ static_assert(testComparisons6Values<month>(0U ,0U), "");
+ static_assert(testComparisons6Values<month>(0U, 1U), "");
+
+// Some 'ok' values as well
+ static_assert(testComparisons6Values<month>( 5U, 5U), "");
+ static_assert(testComparisons6Values<month>( 5U, 10U), "");
+
+ for (unsigned i = 1; i < 10; ++i)
+ for (unsigned j = 10; j < 10; ++j)
+ assert(testComparisons6Values<month>(i, j));
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+
+// 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};
+
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+
+ ASSERT_SAME_TYPE(const std::chrono::month, decltype(std::chrono::January));
+ ASSERT_SAME_TYPE(const std::chrono::month, decltype(std::chrono::February));
+ ASSERT_SAME_TYPE(const std::chrono::month, decltype(std::chrono::March));
+ ASSERT_SAME_TYPE(const std::chrono::month, decltype(std::chrono::April));
+ ASSERT_SAME_TYPE(const std::chrono::month, decltype(std::chrono::May));
+ ASSERT_SAME_TYPE(const std::chrono::month, decltype(std::chrono::June));
+ ASSERT_SAME_TYPE(const std::chrono::month, decltype(std::chrono::July));
+ ASSERT_SAME_TYPE(const std::chrono::month, decltype(std::chrono::August));
+ ASSERT_SAME_TYPE(const std::chrono::month, decltype(std::chrono::September));
+ ASSERT_SAME_TYPE(const std::chrono::month, decltype(std::chrono::October));
+ ASSERT_SAME_TYPE(const std::chrono::month, decltype(std::chrono::November));
+ ASSERT_SAME_TYPE(const std::chrono::month, decltype(std::chrono::December));
+
+ static_assert( std::chrono::January == std::chrono::month(1), "");
+ static_assert( std::chrono::February == std::chrono::month(2), "");
+ static_assert( std::chrono::March == std::chrono::month(3), "");
+ static_assert( std::chrono::April == std::chrono::month(4), "");
+ static_assert( std::chrono::May == std::chrono::month(5), "");
+ static_assert( std::chrono::June == std::chrono::month(6), "");
+ static_assert( std::chrono::July == std::chrono::month(7), "");
+ static_assert( std::chrono::August == std::chrono::month(8), "");
+ static_assert( std::chrono::September == std::chrono::month(9), "");
+ static_assert( std::chrono::October == std::chrono::month(10), "");
+ static_assert( std::chrono::November == std::chrono::month(11), "");
+ static_assert( std::chrono::December == std::chrono::month(12), "");
+
+ assert(std::chrono::January == std::chrono::month(1));
+ assert(std::chrono::February == std::chrono::month(2));
+ assert(std::chrono::March == std::chrono::month(3));
+ assert(std::chrono::April == std::chrono::month(4));
+ assert(std::chrono::May == std::chrono::month(5));
+ assert(std::chrono::June == std::chrono::month(6));
+ assert(std::chrono::July == std::chrono::month(7));
+ assert(std::chrono::August == std::chrono::month(8));
+ assert(std::chrono::September == std::chrono::month(9));
+ assert(std::chrono::October == std::chrono::month(10));
+ assert(std::chrono::November == std::chrono::month(11));
+ assert(std::chrono::December == std::chrono::month(12));
+
+ assert(static_cast<unsigned>(std::chrono::January) == 1);
+ assert(static_cast<unsigned>(std::chrono::February) == 2);
+ assert(static_cast<unsigned>(std::chrono::March) == 3);
+ assert(static_cast<unsigned>(std::chrono::April) == 4);
+ assert(static_cast<unsigned>(std::chrono::May) == 5);
+ assert(static_cast<unsigned>(std::chrono::June) == 6);
+ assert(static_cast<unsigned>(std::chrono::July) == 7);
+ assert(static_cast<unsigned>(std::chrono::August) == 8);
+ assert(static_cast<unsigned>(std::chrono::September) == 9);
+ assert(static_cast<unsigned>(std::chrono::October) == 10);
+ assert(static_cast<unsigned>(std::chrono::November) == 11);
+ assert(static_cast<unsigned>(std::chrono::December) == 12);
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class month;
+
+// constexpr month operator-(const month& x, const months& y) noexcept;
+// Returns: x + -y.
+//
+// constexpr months operator-(const month& x, const month& y) noexcept;
+// Returns: If x.ok() == true and y.ok() == true, returns a value m in the range
+// [months{0}, months{11}] satisfying y + m == x.
+// Otherwise the value returned is unspecified.
+// [Example: January - February == months{11}. —end example]
+
+extern "C" int printf(const char *, ...);
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+template <typename M, typename Ms>
+constexpr bool testConstexpr()
+{
+ {
+ M m{5};
+ Ms offset{3};
+ if (m - offset != M{2}) return false;
+ if (m - M{2} != offset) return false;
+ }
+
+// Check the example
+ if (M{1} - M{2} != Ms{11}) return false;
+ return true;
+}
+
+#include <iostream>
+
+int main()
+{
+ using month = std::chrono::month;
+ using months = std::chrono::months;
+
+ ASSERT_NOEXCEPT(std::declval<month>() - std::declval<months>());
+ ASSERT_NOEXCEPT(std::declval<month>() - std::declval<month>());
+
+ ASSERT_SAME_TYPE(month , decltype(std::declval<month>() - std::declval<months>()));
+ ASSERT_SAME_TYPE(months, decltype(std::declval<month>() - std::declval<month> ()));
+
+static_assert(testConstexpr<month, months>(), "");
+
+ month m{6};
+ for (unsigned i = 1; i <= 12; ++i)
+ {
+ month m1 = m - months{i};
+// months off = m - month {i};
+ int exp = 6 - i;
+ if (exp < 1)
+ exp += 12;
+ assert(static_cast<unsigned>(m1) == static_cast<unsigned>(exp));
+// assert(off.count() == static_cast<unsigned>(exp));
+ }
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class month;
+
+// constexpr month operator+(const month& x, const months& y) noexcept;
+// Returns: month(int{x} + y.count()).
+//
+// constexpr month operator+(const months& x, const month& y) noexcept;
+// Returns:
+// month{modulo(static_cast<long long>(int{x}) + (y.count() - 1), 12) + 1}
+// where modulo(n, 12) computes the remainder of n divided by 12 using Euclidean division.
+// [Note: Given a divisor of 12, Euclidean division truncates towards negative infinity
+// and always produces a remainder in the range of [0, 11].
+// Assuming no overflow in the signed summation, this operation results in a month
+// holding a value in the range [1, 12] even if !x.ok(). —end note]
+// [Example: February + months{11} == January. —end example]
+
+
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+template <typename M, typename Ms>
+constexpr bool testConstexpr()
+{
+ M m{1};
+ Ms offset{4};
+ if (m + offset != M{5}) return false;
+ if (offset + m != M{5}) return false;
+// Check the example
+ if (M{2} + Ms{11} != M{1}) return false;
+ return true;
+}
+
+int main()
+{
+ using month = std::chrono::month;
+ using months = std::chrono::months;
+
+ ASSERT_NOEXCEPT(std::declval<month>() + std::declval<months>());
+ ASSERT_NOEXCEPT(std::declval<months>() + std::declval<month>());
+
+ ASSERT_SAME_TYPE(month, decltype(std::declval<month>() + std::declval<months>()));
+ ASSERT_SAME_TYPE(month, decltype(std::declval<months>() + std::declval<month>() ));
+
+ static_assert(testConstexpr<month, months>(), "");
+
+ month my{2};
+ for (unsigned i = 0; i <= 15; ++i)
+ {
+ month m1 = my + months{i};
+ month m2 = months{i} + my;
+ assert(m1 == m2);
+ unsigned exp = i + 2;
+ while (exp > 12)
+ exp -= 12;
+ assert(static_cast<unsigned>(m1) == exp);
+ assert(static_cast<unsigned>(m2) == exp);
+ }
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+// XFAIL: *
+
+// <chrono>
+// class month;
+
+// template<class charT, class traits>
+// basic_ostream<charT, traits>&
+// operator<<(basic_ostream<charT, traits>& os, const month& m);
+//
+// Effects: If m.ok() == true inserts format(os.getloc(), fmt, m) where fmt is "%b" widened to charT.
+// Otherwise inserts int{m} << " is not a valid month".
+//
+// template<class charT, class traits>
+// basic_ostream<charT, traits>&
+// to_stream(basic_ostream<charT, traits>& os, const charT* fmt, const month& m);
+//
+// Effects: Streams m into os using the format specified by the NTCTS fmt.
+// fmt encoding follows the rules specified in 25.11.
+//
+// template<class charT, class traits, class Alloc = allocator<charT>>
+// basic_istream<charT, traits>&
+// from_stream(basic_istream<charT, traits>& is, const charT* fmt,
+// month& m, basic_string<charT, traits, Alloc>* abbrev = nullptr,
+// minutes* offset = nullptr);
+//
+// Effects: Attempts to parse the input stream is into the month m using the format flags
+// given in the NTCTS fmt as specified in 25.12. If the parse fails to decode a valid month,
+// is.setstate(ios_- base::failbit) shall be called and m shall not be modified.
+// If %Z is used and successfully parsed, that value will be assigned to *abbrev if
+// abbrev is non-null. If %z (or a modified variant) is used and successfully parsed,
+// that value will be assigned to *offset if offset is non-null.
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+#include <iostream>
+
+#include "test_macros.h"
+
+int main()
+{
+ using month = std::chrono::month;
+ std::cout << month{1};
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class month;
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+ using month = std::chrono::month;
+
+ static_assert(std::is_trivially_copyable_v<month>, "");
+ static_assert(std::is_standard_layout_v<month>, "");
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class month_weekday;
+// month_weekday represents the nth weekday of a month, of an as yet unspecified year.
+
+// constexpr month_weekday(const chrono::month& m, const chrono::weekday_indexed& wdi) noexcept;
+// Effects: Constructs an object of type month_weekday by initializing m_ with m, and wdi_ with wdi.
+//
+// constexpr chrono::month month() const noexcept;
+// constexpr chrono::weekday_indexed weekday_indexed() const noexcept;
+// constexpr bool ok() const noexcept;
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+ using month_weekday = std::chrono::month_weekday;
+ using month = std::chrono::month;
+ using weekday = std::chrono::weekday;
+ using weekday_indexed = std::chrono::weekday_indexed;
+
+ ASSERT_NOEXCEPT(month_weekday{month{1}, weekday_indexed{weekday{}, 1}});
+
+ constexpr month_weekday md0{month{}, weekday_indexed{}};
+ static_assert( md0.month() == month{}, "");
+ static_assert( md0.weekday_indexed() == weekday_indexed{}, "");
+ static_assert(!md0.ok(), "");
+
+ constexpr month_weekday md1{std::chrono::January, weekday_indexed{std::chrono::Friday, 4}};
+ static_assert( md1.month() == std::chrono::January, "");
+ static_assert( md1.weekday_indexed() == weekday_indexed{std::chrono::Friday, 4}, "");
+ static_assert( md1.ok(), "");
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class month_weekday;
+
+// constexpr chrono::month month() const noexcept;
+// Returns: wd_
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+ using month_weekday = std::chrono::month_weekday;
+ using month = std::chrono::month;
+ using weekday = std::chrono::weekday;
+ using weekday_indexed = std::chrono::weekday_indexed;
+
+ constexpr weekday Sunday = std::chrono::Sunday;
+
+ ASSERT_NOEXCEPT( std::declval<const month_weekday>().month());
+ ASSERT_SAME_TYPE(month, decltype(std::declval<const month_weekday>().month()));
+
+ static_assert( month_weekday{}.month() == month{}, "");
+
+ for (unsigned i = 1; i <= 50; ++i)
+ {
+ month_weekday md(month{i}, weekday_indexed{Sunday, 1});
+ assert( static_cast<unsigned>(md.month()) == i);
+ }
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class month_weekday;
+
+// constexpr bool ok() const noexcept;
+// Returns: m_.ok() && wdi_.ok().
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+ using month_weekday = std::chrono::month_weekday;
+ using month = std::chrono::month;
+ using weekday = std::chrono::weekday;
+ using weekday_indexed = std::chrono::weekday_indexed;
+
+ constexpr weekday Sunday = std::chrono::Sunday;
+
+ ASSERT_NOEXCEPT( std::declval<const month_weekday>().ok());
+ ASSERT_SAME_TYPE(bool, decltype(std::declval<const month_weekday>().ok()));
+
+ static_assert(!month_weekday{month{}, weekday_indexed{}}.ok(), "");
+ static_assert( month_weekday{std::chrono::May, weekday_indexed{Sunday, 2}}.ok(), "");
+
+ assert(!(month_weekday(std::chrono::April, weekday_indexed{Sunday, 0}).ok()));
+ assert( (month_weekday{std::chrono::March, weekday_indexed{Sunday, 1}}.ok()));
+
+ for (unsigned i = 1; i <= 12; ++i)
+ for (unsigned j = 0; j <= 6; ++j)
+ {
+ month_weekday mwd{month{i}, weekday_indexed{Sunday, j}};
+ assert(mwd.ok() == (j >= 1 && j <= 5));
+ }
+
+// If the month is not ok, all the weekday_indexed are bad
+ for (unsigned i = 1; i <= 10; ++i)
+ assert(!(month_weekday{month{13}, weekday_indexed{Sunday, i}}.ok()));
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class month_weekday;
+
+// constexpr chrono::weekday_indexed weekday_indexed() const noexcept;
+// Returns: wdi_
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+ using month_weekday = std::chrono::month_weekday;
+ using month = std::chrono::month;
+ using weekday = std::chrono::weekday;
+ using weekday_indexed = std::chrono::weekday_indexed;
+
+ constexpr weekday Sunday = std::chrono::Sunday;
+
+ ASSERT_NOEXCEPT( std::declval<const month_weekday>().weekday_indexed());
+ ASSERT_SAME_TYPE(weekday_indexed, decltype(std::declval<const month_weekday>().weekday_indexed()));
+
+ static_assert( month_weekday{month{}, weekday_indexed{}}.weekday_indexed() == weekday_indexed{}, "");
+
+ for (unsigned i = 1; i <= 10; ++i)
+ {
+ month_weekday md(std::chrono::March, weekday_indexed{Sunday, i});
+ assert( static_cast<unsigned>(md.weekday_indexed().weekday() == Sunday));
+ assert( static_cast<unsigned>(md.weekday_indexed().index() == i));
+ }
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class month_weekday;
+
+// constexpr bool operator==(const month_weekday& x, const month_weekday& y) noexcept;
+// Returns: x.month() == y.month() && x.day() == y.day().
+//
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+#include "test_comparisons.h"
+
+int main()
+{
+ using month_weekday = std::chrono::month_weekday;
+ using month = std::chrono::month;
+ using weekday_indexed = std::chrono::weekday_indexed;
+ using weekday = std::chrono::weekday;
+
+ constexpr weekday Sunday = std::chrono::Sunday;
+ constexpr weekday Monday = std::chrono::Monday;
+
+ AssertComparisons2AreNoexcept<month_weekday>();
+ AssertComparisons2ReturnBool<month_weekday>();
+
+ static_assert( testComparisons2(
+ month_weekday{std::chrono::January, weekday_indexed{Sunday, 1}},
+ month_weekday{std::chrono::January, weekday_indexed{Sunday, 1}},
+ true), "");
+
+ static_assert( testComparisons2(
+ month_weekday{std::chrono::January, weekday_indexed{Sunday, 1}},
+ month_weekday{std::chrono::January, weekday_indexed{Sunday, 2}},
+ false), "");
+
+ static_assert( testComparisons2(
+ month_weekday{std::chrono::January, weekday_indexed{Sunday, 1}},
+ month_weekday{std::chrono::February, weekday_indexed{Sunday, 1}},
+ false), "");
+
+ static_assert( testComparisons2(
+ month_weekday{std::chrono::January, weekday_indexed{Monday, 1}},
+ month_weekday{std::chrono::January, weekday_indexed{Sunday, 2}},
+ false), "");
+
+ static_assert( testComparisons2(
+ month_weekday{std::chrono::January, weekday_indexed{Monday, 1}},
+ month_weekday{std::chrono::February, weekday_indexed{Sunday, 1}},
+ false), "");
+
+// same day, different months
+ for (unsigned i = 1; i < 12; ++i)
+ for (unsigned j = 1; j < 12; ++j)
+ assert((testComparisons2(
+ month_weekday{month{i}, weekday_indexed{Sunday, 1}},
+ month_weekday{month{j}, weekday_indexed{Sunday, 1}},
+ i == j)));
+
+// same month, different weeks
+ for (unsigned i = 1; i < 5; ++i)
+ for (unsigned j = 1; j < 5; ++j)
+ assert((testComparisons2(
+ month_weekday{month{2}, weekday_indexed{Sunday, i}},
+ month_weekday{month{2}, weekday_indexed{Sunday, j}},
+ i == j)));
+
+// same month, different days
+ for (unsigned i = 0; i < 6; ++i)
+ for (unsigned j = 0; j < 6; ++j)
+ assert((testComparisons2(
+ month_weekday{month{2}, weekday_indexed{weekday{i}, 2}},
+ month_weekday{month{2}, weekday_indexed{weekday{j}, 2}},
+ i == j)));
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+// XFAIL: *
+
+// <chrono>
+// class month_weekday;
+
+// template<class charT, class traits>
+// basic_ostream<charT, traits>&
+// operator<<(basic_ostream<charT, traits>& os, const month_weekday& mwd);
+//
+// Returns: os << mwd.month() << '/' << mwd.weekday_indexed().
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+#include <iostream>
+
+#include "test_macros.h"
+
+int main()
+{
+ using month_weekday = std::chrono::month_weekday;
+ using month = std::chrono::month;
+ using weekday_indexed = std::chrono::weekday_indexed;
+ using weekday = std::chrono::weekday;
+
+ std::cout << month_weekday{month{1}, weekday_indexed{weekday{3}, 3}};
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class month_weekday;
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+ using month_weekday = std::chrono::month_weekday;
+
+ static_assert(std::is_trivially_copyable_v<month_weekday>, "");
+ static_assert(std::is_standard_layout_v<month_weekday>, "");
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class month_weekday_last;
+
+// constexpr month_weekday_last(const chrono::month& m,
+// const chrono::weekday_last& wdl) noexcept;
+//
+// Effects: Constructs an object of type month_weekday_last by
+// initializing m_ with m, and wdl_ with wdl.
+//
+// constexpr chrono::month month() const noexcept;
+// constexpr chrono::weekday_last weekday_last() const noexcept;
+// constexpr bool ok() const noexcept;
+
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+ using month = std::chrono::month;
+ using weekday = std::chrono::weekday;
+ using weekday_last = std::chrono::weekday_last;
+ using month_weekday_last = std::chrono::month_weekday_last;
+
+ constexpr month January = std::chrono::January;
+ constexpr weekday Tuesday = std::chrono::Tuesday;
+
+ ASSERT_NOEXCEPT(month_weekday_last{January, weekday_last{Tuesday}});
+
+// bad month
+ constexpr month_weekday_last mwdl1{month{}, weekday_last{Tuesday}};
+ static_assert( mwdl1.month() == month{}, "");
+ static_assert( mwdl1.weekday_last() == weekday_last{Tuesday}, "");
+ static_assert(!mwdl1.ok(), "");
+
+// bad weekday_last
+ constexpr month_weekday_last mwdl2{January, weekday_last{weekday{16}}};
+ static_assert( mwdl2.month() == January, "");
+ static_assert( mwdl2.weekday_last() == weekday_last{weekday{16}}, "");
+ static_assert(!mwdl2.ok(), "");
+
+// Good month and weekday_last
+ constexpr month_weekday_last mwdl3{January, weekday_last{weekday{4}}};
+ static_assert( mwdl3.month() == January, "");
+ static_assert( mwdl3.weekday_last() == weekday_last{weekday{4}}, "");
+ static_assert( mwdl3.ok(), "");
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class month_weekday_last;
+
+// constexpr chrono::month month() const noexcept;
+// Returns: m_
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+ using month = std::chrono::month;
+ using weekday = std::chrono::weekday;
+ using weekday_last = std::chrono::weekday_last;
+ using month_weekday_last = std::chrono::month_weekday_last;
+
+ constexpr weekday Tuesday = std::chrono::Tuesday;
+
+ ASSERT_NOEXCEPT( std::declval<const month_weekday_last>().month());
+ ASSERT_SAME_TYPE(month, decltype(std::declval<const month_weekday_last>().month()));
+
+ static_assert( month_weekday_last{month{}, weekday_last{Tuesday}}.month() == month{}, "");
+
+ for (unsigned i = 1; i <= 50; ++i)
+ {
+ month_weekday_last mdl(month{i}, weekday_last{Tuesday});
+ assert( static_cast<unsigned>(mdl.month()) == i);
+ }
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class month_weekday_last;
+
+// constexpr bool ok() const noexcept;
+// Returns: m_.ok() && wdl_.ok().
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+ using month = std::chrono::month;
+ using weekday = std::chrono::weekday;
+ using weekday_last = std::chrono::weekday_last;
+ using month_weekday_last = std::chrono::month_weekday_last;
+
+ constexpr month January = std::chrono::January;
+ constexpr weekday Tuesday = std::chrono::Tuesday;
+ constexpr weekday_last lastTuesday = weekday_last{Tuesday};
+
+ ASSERT_NOEXCEPT( std::declval<const month_weekday_last>().ok());
+ ASSERT_SAME_TYPE(bool, decltype(std::declval<const month_weekday_last>().ok()));
+
+ static_assert(!month_weekday_last{month{}, lastTuesday}.ok(), ""); // Bad month
+ static_assert(!month_weekday_last{January, weekday_last{weekday{12}}}.ok(), ""); // Bad month
+ static_assert( month_weekday_last{January, lastTuesday}.ok(), ""); // Both OK
+
+ for (unsigned i = 0; i <= 50; ++i)
+ {
+ month_weekday_last mwdl{month{i}, lastTuesday};
+ assert( mwdl.ok() == month{i}.ok());
+ }
+
+ for (unsigned i = 0; i <= 50; ++i)
+ {
+ month_weekday_last mwdl{January, weekday_last{weekday{i}}};
+ assert( mwdl.ok() == weekday_last{weekday{i}}.ok());
+ }
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class month_weekday_last;
+
+// constexpr chrono::weekday_last weekday_last() const noexcept;
+// Returns: wdl_
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+ using month = std::chrono::month;
+ using weekday = std::chrono::weekday;
+ using weekday_last = std::chrono::weekday_last;
+ using month_weekday_last = std::chrono::month_weekday_last;
+
+ constexpr month January = std::chrono::January;
+ constexpr weekday Tuesday = std::chrono::Tuesday;
+ constexpr weekday_last lastTuesday = weekday_last{Tuesday};
+
+ ASSERT_NOEXCEPT( std::declval<const month_weekday_last>().weekday_last());
+ ASSERT_SAME_TYPE(weekday_last, decltype(std::declval<const month_weekday_last>().weekday_last()));
+
+ static_assert( month_weekday_last{month{}, lastTuesday}.weekday_last() == lastTuesday, "");
+
+ for (unsigned i = 1; i <= 50; ++i)
+ {
+ month_weekday_last mdl(January, weekday_last{weekday{i}});
+ assert( static_cast<unsigned>(mdl.weekday_last().weekday()) == i);
+ }
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class month_weekday_last;
+
+// constexpr bool operator==(const month_weekday_last& x, const month_weekday_last& y) noexcept;
+// Returns: x.month() == y.month()
+//
+// constexpr bool operator< (const month_weekday_last& x, const month_weekday_last& y) noexcept;
+// Returns: x.month() < y.month()
+
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+#include "test_comparisons.h"
+
+int main()
+{
+ using month = std::chrono::month;
+ using weekday_last = std::chrono::weekday_last;
+ using weekday = std::chrono::weekday;
+ using month_weekday_last = std::chrono::month_weekday_last;
+
+ constexpr month January = std::chrono::January;
+ constexpr weekday Tuesday = std::chrono::Tuesday;
+ constexpr weekday Wednesday = std::chrono::Wednesday;
+
+ AssertComparisons2AreNoexcept<month_weekday_last>();
+ AssertComparisons2ReturnBool<month_weekday_last>();
+
+ static_assert( testComparisons2(
+ month_weekday_last{std::chrono::January, weekday_last{Tuesday}},
+ month_weekday_last{std::chrono::January, weekday_last{Tuesday}},
+ true), "");
+
+ static_assert( testComparisons2(
+ month_weekday_last{std::chrono::January, weekday_last{Tuesday}},
+ month_weekday_last{std::chrono::January, weekday_last{Wednesday}},
+ false), "");
+
+// vary the months
+ for (unsigned i = 1; i < 12; ++i)
+ for (unsigned j = 1; j < 12; ++j)
+ assert((testComparisons2(
+ month_weekday_last{month{i}, weekday_last{Tuesday}},
+ month_weekday_last{month{j}, weekday_last{Tuesday}},
+ i == j)));
+
+// vary the weekday
+ for (unsigned i = 0; i < 6; ++i)
+ for (unsigned j = 0; j < 6; ++j)
+ assert((testComparisons2(
+ month_weekday_last{January, weekday_last{weekday{i}}},
+ month_weekday_last{January, weekday_last{weekday{j}}},
+ i == j)));
+
+// both different
+ assert((testComparisons2(
+ month_weekday_last{month{1}, weekday_last{weekday{1}}},
+ month_weekday_last{month{2}, weekday_last{weekday{2}}},
+ false)));
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+// XFAIL: *
+
+// <chrono>
+// class month_weekday_last;
+//
+// template<class charT, class traits>
+// basic_ostream<charT, traits>&
+// operator<<(basic_ostream<charT, traits>& os, const month_weekday_last& mdl);
+//
+// Returns: os << mdl.month() << "/last".
+
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+#include <iostream>
+
+#include "test_macros.h"
+
+int main()
+{
+ using month_weekday_last = std::chrono::month_weekday_last;
+ using month = std::chrono::month;
+ using weekday = std::chrono::weekday;
+ using weekday_last = std::chrono::weekday_last;
+
+ std::cout << month_weekday_last{month{1}, weekday_last{weekday{3}}};
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+
+// class month_weekday_last;
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+ using month_weekday_last = std::chrono::month_weekday_last;
+
+ static_assert(std::is_trivially_copyable_v<month_weekday_last>, "");
+ static_assert(std::is_standard_layout_v<month_weekday_last>, "");
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class month_day;
+
+// constexpr month_day
+// operator/(const month& m, const day& d) noexcept;
+// Returns: {m, d}.
+//
+// constexpr month_day
+// operator/(const day& d, const month& m) noexcept;
+// Returns: m / d.
+
+// constexpr month_day
+// operator/(const month& m, int d) noexcept;
+// Returns: m / day(d).
+//
+// constexpr month_day
+// operator/(int m, const day& d) noexcept;
+// Returns: month(m) / d.
+//
+// constexpr month_day
+// operator/(const day& d, int m) noexcept;
+// Returns: month(m) / d.
+
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+#include "test_comparisons.h"
+
+int main()
+{
+ using month_day = std::chrono::month_day;
+ using month = std::chrono::month;
+ using day = std::chrono::day;
+
+ constexpr month February = std::chrono::February;
+
+ { // operator/(const month& m, const day& d) (and switched)
+ ASSERT_NOEXCEPT ( February/day{1});
+ ASSERT_SAME_TYPE(month_day, decltype(February/day{1}));
+ ASSERT_NOEXCEPT ( day{1}/February);
+ ASSERT_SAME_TYPE(month_day, decltype(day{1}/February));
+
+ for (int i = 1; i <= 12; ++i)
+ for (unsigned j = 0; j <= 30; ++j)
+ {
+ month m(i);
+ day d{j};
+ month_day md1 = m/d;
+ month_day md2 = d/m;
+ assert(md1.month() == m);
+ assert(md1.day() == d);
+ assert(md2.month() == m);
+ assert(md2.day() == d);
+ assert(md1 == md2);
+ }
+ }
+
+
+ { // operator/(const month& m, int d) (NOT switched)
+ ASSERT_NOEXCEPT ( February/2);
+ ASSERT_SAME_TYPE(month_day, decltype(February/2));
+
+ for (int i = 1; i <= 12; ++i)
+ for (unsigned j = 0; j <= 30; ++j)
+ {
+ month m(i);
+ day d(j);
+ month_day md1 = m/j;
+ assert(md1.month() == m);
+ assert(md1.day() == d);
+ }
+ }
+
+
+ { // operator/(const day& d, int m) (and switched)
+ ASSERT_NOEXCEPT ( day{2}/2);
+ ASSERT_SAME_TYPE(month_day, decltype(day{2}/2));
+ ASSERT_NOEXCEPT ( 2/day{2});
+ ASSERT_SAME_TYPE(month_day, decltype(2/day{2}));
+
+ for (int i = 1; i <= 12; ++i)
+ for (unsigned j = 0; j <= 30; ++j)
+ {
+ month m(i);
+ day d(j);
+ month_day md1 = d/i;
+ month_day md2 = i/d;
+ assert(md1.month() == m);
+ assert(md1.day() == d);
+ assert(md2.month() == m);
+ assert(md2.day() == d);
+ assert(md1 == md2);
+ }
+ }
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class month_day_last;
+
+// constexpr month_day_last
+// operator/(const month& m, last_spec) noexcept;
+// Returns: month_day_last{m}.
+//
+// constexpr month_day_last
+// operator/(int m, last_spec) noexcept;
+// Returns: month(m) / last.
+//
+// constexpr month_day_last
+// operator/(last_spec, const month& m) noexcept;
+// Returns: m / last.
+//
+// constexpr month_day_last
+// operator/(last_spec, int m) noexcept;
+// Returns: month(m) / last.
+//
+//
+// [Note: A month_day_last object can be constructed using the expression m/last or last/m,
+// where m is an expression of type month. — end note]
+// [Example:
+// constexpr auto mdl = February/last; // mdl is the last day of February of an as yet unspecified year
+// static_assert(mdl.month() == February);
+// --end example]
+
+
+
+
+
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+#include "test_comparisons.h"
+
+int main()
+{
+ using month = std::chrono::month;
+ using month_day_last = std::chrono::month_day_last;
+
+ constexpr month February = std::chrono::February;
+ constexpr std::chrono::last_spec last = std::chrono::last;
+
+ ASSERT_SAME_TYPE(month_day_last, decltype(last/February));
+ ASSERT_SAME_TYPE(month_day_last, decltype(February/last));
+
+// Run the example
+ {
+ constexpr auto mdl = February/std::chrono::last;
+ static_assert(mdl.month() == February, "");
+ }
+
+ { // operator/(const month& m, last_spec) and switched
+ ASSERT_NOEXCEPT ( last/February);
+ ASSERT_SAME_TYPE(month_day_last, decltype(last/February));
+ ASSERT_NOEXCEPT ( February/last);
+ ASSERT_SAME_TYPE(month_day_last, decltype(February/last));
+
+ static_assert((last/February).month() == February, "");
+ static_assert((February/last).month() == February, "");
+
+ for (unsigned i = 1; i < 12; ++i)
+ {
+ month m{i};
+ month_day_last mdl1 = last/m;
+ month_day_last mdl2 = m/last;
+ assert(mdl1.month() == m);
+ assert(mdl2.month() == m);
+ assert(mdl1 == mdl2);
+ }
+ }
+
+ { // operator/(int, last_spec) and switched
+ ASSERT_NOEXCEPT ( last/2);
+ ASSERT_SAME_TYPE(month_day_last, decltype(last/2));
+ ASSERT_NOEXCEPT ( 2/last);
+ ASSERT_SAME_TYPE(month_day_last, decltype(2/last));
+
+ static_assert((last/2).month() == February, "");
+ static_assert((2/last).month() == February, "");
+
+ for (unsigned i = 1; i < 12; ++i)
+ {
+ month m{i};
+ month_day_last mdl1 = last/i;
+ month_day_last mdl2 = i/last;
+ assert(mdl1.month() == m);
+ assert(mdl2.month() == m);
+ assert(mdl1 == mdl2);
+ }
+ }
+
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class month_weekday;
+
+// constexpr month_weekday
+// operator/(const month& m, const weekday_indexed& wdi) noexcept;
+// Returns: {m, wdi}.
+//
+// constexpr month_weekday
+// operator/(int m, const weekday_indexed& wdi) noexcept;
+// Returns: month(m) / wdi.
+//
+// constexpr month_weekday
+// operator/(const weekday_indexed& wdi, const month& m) noexcept;
+// Returns: m / wdi. constexpr month_weekday
+//
+// constexpr month_weekday
+// operator/(const weekday_indexed& wdi, int m) noexcept;
+// Returns: month(m) / wdi.
+
+
+//
+// [Example:
+// constexpr auto mwd = February/Tuesday[3]; // mwd is the third Tuesday of February of an as yet unspecified year
+// static_assert(mwd.month() == February);
+// static_assert(mwd.weekday_indexed() == Tuesday[3]);
+// —end example]
+
+
+
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+#include "test_comparisons.h"
+
+int main()
+{
+ using month_weekday = std::chrono::month_weekday;
+ using month = std::chrono::month;
+ using weekday = std::chrono::weekday;
+ using weekday_indexed = std::chrono::weekday_indexed;
+
+ constexpr weekday Tuesday = std::chrono::Tuesday;
+ constexpr month February = std::chrono::February;
+
+ { // operator/(const month& m, const weekday_indexed& wdi) (and switched)
+ ASSERT_NOEXCEPT (February/Tuesday[2]);
+ ASSERT_SAME_TYPE(month_weekday, decltype(February/Tuesday[2]));
+ ASSERT_NOEXCEPT (Tuesday[2]/February);
+ ASSERT_SAME_TYPE(month_weekday, decltype(Tuesday[2]/February));
+
+ // Run the example
+ {
+ constexpr month_weekday wdi = February/Tuesday[3];
+ static_assert(wdi.month() == February, "");
+ static_assert(wdi.weekday_indexed() == Tuesday[3], "");
+ }
+
+ for (int i = 1; i <= 12; ++i)
+ for (unsigned j = 0; j <= 6; ++j)
+ for (unsigned k = 1; k <= 5; ++k)
+ {
+ month m(i);
+ weekday_indexed wdi = weekday{j}[k];
+ month_weekday mwd1 = m/wdi;
+ month_weekday mwd2 = wdi/m;
+ assert(mwd1.month() == m);
+ assert(mwd1.weekday_indexed() == wdi);
+ assert(mwd2.month() == m);
+ assert(mwd2.weekday_indexed() == wdi);
+ assert(mwd1 == mwd2);
+ }
+ }
+
+
+ { // operator/(int m, const weekday_indexed& wdi) (and switched)
+ ASSERT_NOEXCEPT (2/Tuesday[2]);
+ ASSERT_SAME_TYPE(month_weekday, decltype(2/Tuesday[2]));
+ ASSERT_NOEXCEPT (Tuesday[2]/2);
+ ASSERT_SAME_TYPE(month_weekday, decltype(Tuesday[2]/2));
+
+ // Run the example
+ {
+ constexpr month_weekday wdi = 2/Tuesday[3];
+ static_assert(wdi.month() == February, "");
+ static_assert(wdi.weekday_indexed() == Tuesday[3], "");
+ }
+
+ for (int i = 1; i <= 12; ++i)
+ for (unsigned j = 0; j <= 6; ++j)
+ for (unsigned k = 1; k <= 5; ++k)
+ {
+ weekday_indexed wdi = weekday{j}[k];
+ month_weekday mwd1 = i/wdi;
+ month_weekday mwd2 = wdi/i;
+ assert(mwd1.month() == month(i));
+ assert(mwd1.weekday_indexed() == wdi);
+ assert(mwd2.month() == month(i));
+ assert(mwd2.weekday_indexed() == wdi);
+ assert(mwd1 == mwd2);
+ }
+ }
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class month_weekday_last;
+
+// constexpr month_weekday_last
+// operator/(const month& m, const weekday_last& wdl) noexcept;
+// Returns: {m, wdl}.
+//
+// constexpr month_weekday_last
+// operator/(int m, const weekday_last& wdl) noexcept;
+// Returns: month(m) / wdl.
+//
+// constexpr month_weekday_last
+// operator/(const weekday_last& wdl, const month& m) noexcept;
+// Returns: m / wdl.
+//
+// constexpr month_weekday_last
+// operator/(const weekday_last& wdl, int m) noexcept;
+// Returns: month(m) / wdl.
+
+
+
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+#include "test_comparisons.h"
+
+int main()
+{
+ using month_weekday = std::chrono::month_weekday;
+ using month = std::chrono::month;
+ using weekday = std::chrono::weekday;
+ using weekday_last = std::chrono::weekday_last;
+ using month_weekday_last = std::chrono::month_weekday_last;
+
+ constexpr weekday Tuesday = std::chrono::Tuesday;
+ constexpr month February = std::chrono::February;
+ constexpr std::chrono::last_spec last = std::chrono::last;
+
+ { // operator/(const month& m, const weekday_last& wdi) (and switched)
+ ASSERT_NOEXCEPT (February/Tuesday[last]);
+ ASSERT_SAME_TYPE(month_weekday_last, decltype(February/Tuesday[last]));
+ ASSERT_NOEXCEPT (Tuesday[last]/February);
+ ASSERT_SAME_TYPE(month_weekday_last, decltype(Tuesday[last]/February));
+
+ // Run the example
+ {
+ constexpr month_weekday_last wdi = February/Tuesday[last];
+ static_assert(wdi.month() == February, "");
+ static_assert(wdi.weekday_last() == Tuesday[last], "");
+ }
+
+ for (int i = 1; i <= 12; ++i)
+ for (unsigned j = 0; j <= 6; ++j)
+ {
+ month m(i);
+ weekday_last wdi = weekday{j}[last];
+ month_weekday_last mwd1 = m/wdi;
+ month_weekday_last mwd2 = wdi/m;
+ assert(mwd1.month() == m);
+ assert(mwd1.weekday_last() == wdi);
+ assert(mwd2.month() == m);
+ assert(mwd2.weekday_last() == wdi);
+ assert(mwd1 == mwd2);
+ }
+ }
+
+
+ { // operator/(int m, const weekday_last& wdi) (and switched)
+ ASSERT_NOEXCEPT (2/Tuesday[2]);
+ ASSERT_SAME_TYPE(month_weekday_last, decltype(2/Tuesday[last]));
+ ASSERT_NOEXCEPT (Tuesday[2]/2);
+ ASSERT_SAME_TYPE(month_weekday_last, decltype(Tuesday[last]/2));
+
+ // Run the example
+ {
+ constexpr month_weekday wdi = 2/Tuesday[3];
+ static_assert(wdi.month() == February, "");
+ static_assert(wdi.weekday_indexed() == Tuesday[3], "");
+ }
+
+ for (int i = 1; i <= 12; ++i)
+ for (unsigned j = 0; j <= 6; ++j)
+ {
+ weekday_last wdi = weekday{j}[last];
+ month_weekday_last mwd1 = i/wdi;
+ month_weekday_last mwd2 = wdi/i;
+ assert(mwd1.month() == month(i));
+ assert(mwd1.weekday_last() == wdi);
+ assert(mwd2.month() == month(i));
+ assert(mwd2.weekday_last() == wdi);
+ assert(mwd1 == mwd2);
+ }
+ }
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class year_month;
+
+// constexpr year_month operator/(const year& y, const month& m) noexcept;
+// Returns: {y, m}.
+//
+// constexpr year_month operator/(const year& y, int m) noexcept;
+// Returns: y / month(m).
+
+
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+#include "test_comparisons.h"
+
+int main()
+{
+ using month = std::chrono::month;
+ using year = std::chrono::year;
+ using year_month = std::chrono::year_month;
+
+ constexpr month February = std::chrono::February;
+
+ { // operator/(const year& y, const month& m)
+ ASSERT_NOEXCEPT ( year{2018}/February);
+ ASSERT_SAME_TYPE(year_month, decltype(year{2018}/February));
+
+ static_assert((year{2018}/February).year() == year{2018}, "");
+ static_assert((year{2018}/February).month() == month{2}, "");
+ for (int i = 1000; i <= 1030; ++i)
+ for (unsigned j = 1; j <= 12; ++j)
+ {
+ year_month ym = year{i}/month{j};
+ assert(static_cast<int>(ym.year()) == i);
+ assert(static_cast<unsigned>(ym.month()) == j);
+ }
+ }
+
+
+ { // operator/(const year& y, const int m)
+ ASSERT_NOEXCEPT ( year{2018}/4);
+ ASSERT_SAME_TYPE(year_month, decltype(year{2018}/4));
+
+ static_assert((year{2018}/2).year() == year{2018}, "");
+ static_assert((year{2018}/2).month() == month{2}, "");
+
+ for (int i = 1000; i <= 1030; ++i)
+ for (unsigned j = 1; j <= 12; ++j)
+ {
+ year_month ym = year{i}/j;
+ assert(static_cast<int>(ym.year()) == i);
+ assert(static_cast<unsigned>(ym.month()) == j);
+ }
+ }
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class year_month_day;
+
+// constexpr year_month_day
+// operator/(const year_month& ym, const day& d) noexcept;
+// Returns: {ym.year(), ym.month(), d}.
+//
+// constexpr year_month_day
+// operator/(const year_month& ym, int d) noexcept;
+// Returns: ym / day(d).
+//
+// constexpr year_month_day
+// operator/(const year& y, const month_day& md) noexcept;
+// Returns: y / md.month() / md.day().
+//
+// constexpr year_month_day
+// operator/(int y, const month_day& md) noexcept;
+// Returns: year(y) / md.
+//
+// constexpr year_month_day
+// operator/(const month_day& md, const year& y) noexcept;
+// Returns: y / md.
+//
+// constexpr year_month_day
+// operator/(const month_day& md, int y) noexcept;
+// Returns: year(y) / md.
+
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+#include "test_comparisons.h"
+
+int main()
+{
+ using year = std::chrono::year;
+ using month = std::chrono::month;
+ using day = std::chrono::day;
+ using year_month = std::chrono::year_month;
+ using month_day = std::chrono::month_day;
+ using year_month_day = std::chrono::year_month_day;
+ using weekday = std::chrono::weekday;
+
+ constexpr month February = std::chrono::February;
+ constexpr year_month Feb2018{year{2018}, February};
+
+ { // operator/(const year_month& ym, const day& d)
+ ASSERT_NOEXCEPT ( Feb2018/day{2});
+ ASSERT_SAME_TYPE(year_month_day, decltype(Feb2018/day{2}));
+
+ static_assert((Feb2018/day{2}).month() == February, "");
+ static_assert((Feb2018/day{2}).day() == day{2}, "");
+
+ for (int i = 1000; i < 1010; ++i)
+ for (int j = 1; j <= 12; ++j)
+ for (unsigned k = 0; k <= 28; ++k)
+ {
+ year y(i);
+ month m(j);
+ day d(k);
+ year_month ym(y, m);
+ year_month_day ymd = ym/d;
+ assert(ymd.year() == y);
+ assert(ymd.month() == m);
+ assert(ymd.day() == d);
+ }
+ }
+
+
+ { // operator/(const year_month& ym, int d)
+ ASSERT_NOEXCEPT ( Feb2018/2);
+ ASSERT_SAME_TYPE(year_month_day, decltype(Feb2018/2));
+
+ static_assert((Feb2018/2).month() == February, "");
+ static_assert((Feb2018/2).day() == day{2}, "");
+
+ for (int i = 1000; i < 1010; ++i)
+ for (int j = 1; j <= 12; ++j)
+ for (unsigned k = 0; k <= 28; ++k)
+ {
+ year y(i);
+ month m(j);
+ day d(k);
+ year_month ym(y, m);
+ year_month_day ymd = ym/k;
+ assert(ymd.year() == y);
+ assert(ymd.month() == m);
+ assert(ymd.day() == d);
+ }
+ }
+
+
+ { // operator/(const year_month& ym, int d)
+ ASSERT_NOEXCEPT ( Feb2018/2);
+ ASSERT_SAME_TYPE(year_month_day, decltype(Feb2018/2));
+
+ static_assert((Feb2018/2).month() == February, "");
+ static_assert((Feb2018/2).day() == day{2}, "");
+
+ for (int i = 1000; i < 1010; ++i)
+ for (int j = 1; j <= 12; ++j)
+ for (unsigned k = 0; k <= 28; ++k)
+ {
+ year y(i);
+ month m(j);
+ day d(k);
+ year_month ym(y, m);
+ year_month_day ymd = ym/k;
+ assert(ymd.year() == y);
+ assert(ymd.month() == m);
+ assert(ymd.day() == d);
+ }
+ }
+
+
+
+
+ { // operator/(const year& y, const month_day& md) (and switched)
+ ASSERT_NOEXCEPT ( year{2018}/month_day{February, day{2}});
+ ASSERT_SAME_TYPE(year_month_day, decltype(year{2018}/month_day{February, day{2}}));
+ ASSERT_NOEXCEPT ( month_day{February, day{2}}/year{2018});
+ ASSERT_SAME_TYPE(year_month_day, decltype(month_day{February, day{2}}/year{2018}));
+
+ static_assert((year{2018}/month_day{February, day{2}}).month() == February, "" );
+ static_assert((year{2018}/month_day{February, day{2}}).day() == day{2}, "" );
+ static_assert((month_day{February, day{2}}/year{2018}).month() == February, "" );
+ static_assert((month_day{February, day{2}}/year{2018}).day() == day{2}, "" );
+
+ for (int i = 1000; i < 1010; ++i)
+ for (int j = 1; j <= 12; ++j)
+ for (unsigned k = 0; k <= 28; ++k)
+ {
+ year y(i);
+ month m(j);
+ day d(k);
+ month_day md(m, d);
+ year_month_day ymd1 = y/md;
+ year_month_day ymd2 = md/y;
+ assert(ymd1.year() == y);
+ assert(ymd2.year() == y);
+ assert(ymd1.month() == m);
+ assert(ymd2.month() == m);
+ assert(ymd1.day() == d);
+ assert(ymd2.day() == d);
+ assert(ymd1 == ymd2);
+ }
+ }
+
+ { // operator/(const month_day& md, int y) (and switched)
+ ASSERT_NOEXCEPT ( 2018/month_day{February, day{2}});
+ ASSERT_SAME_TYPE(year_month_day, decltype(2018/month_day{February, day{2}}));
+ ASSERT_NOEXCEPT ( month_day{February, day{2}}/2018);
+ ASSERT_SAME_TYPE(year_month_day, decltype(month_day{February, day{2}}/2018));
+
+ static_assert((2018/month_day{February, day{2}}).month() == February, "" );
+ static_assert((2018/month_day{February, day{2}}).day() == day{2}, "" );
+ static_assert((month_day{February, day{2}}/2018).month() == February, "" );
+ static_assert((month_day{February, day{2}}/2018).day() == day{2}, "" );
+
+ for (int i = 1000; i < 1010; ++i)
+ for (int j = 1; j <= 12; ++j)
+ for (unsigned k = 0; k <= 28; ++k)
+ {
+ year y(i);
+ month m(j);
+ day d(k);
+ month_day md(m, d);
+ year_month_day ymd1 = i/md;
+ year_month_day ymd2 = md/i;
+ assert(ymd1.year() == y);
+ assert(ymd2.year() == y);
+ assert(ymd1.month() == m);
+ assert(ymd2.month() == m);
+ assert(ymd1.day() == d);
+ assert(ymd2.day() == d);
+ assert(ymd1 == ymd2);
+ }
+ }
+
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+// <chrono>
+// class year_month_day_last;
+
+// constexpr year_month_day_last
+// operator/(const year_month& ym, last_spec) noexcept;
+// Returns: {ym.year(), month_day_last{ym.month()}}.
+
+
+// constexpr year_month_day_last
+// operator/(const year& y, const month_day_last& mdl) noexcept;
+// Returns: {y, mdl}.
+//
+// constexpr year_month_day_last
+// operator/(int y, const month_day_last& mdl) noexcept;
+// Returns: year(y) / mdl.
+//
+// constexpr year_month_day_last
+// operator/(const month_day_last& mdl, const year& y) noexcept;
+// Returns: y / mdl.
+//
+// constexpr year_month_day_last
+// operator/(const month_day_last& mdl, int y) noexcept;
+// Returns: year(y) / mdl.
+
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+#include "test_comparisons.h"
+
+int main()
+{
+ using month_weekday = std::chrono::month_weekday;
+ using month = std::chrono::month;
+ using year_month = std::chrono::year_month;
+ using year = std::chrono::year;
+ using weekday_last = std::chrono::weekday_last;
+ using weekday = std::chrono::weekday;
+ using month_weekday_last = std::chrono::month_weekday_last;
+ using month_day_last = std::chrono::month_day_last;
+ using year_month_day_last = std::chrono::year_month_day_last;
+
+ constexpr month February = std::chrono::February;
+ constexpr std::chrono::last_spec last = std::chrono::last;
+
+ { // operator/(const year_month& ym, last_spec)
+ constexpr year_month Feb2018{year{2018}, February};
+
+ ASSERT_NOEXCEPT ( Feb2018/last);
+ ASSERT_SAME_TYPE(year_month_day_last, decltype(Feb2018/last));
+
+ static_assert((Feb2018/last).year() == year{2018}, "");
+ static_assert((Feb2018/last).month() == February, "");
+
+ for (int i = 1000; i < 1010; ++i)
+ for (unsigned j = 1; j <= 12; ++j)
+ {
+ year y{i};
+ month m{j};
+ year_month_day_last ymdl = year_month{y,m}/last;
+ assert(ymdl.year() == y);
+ assert(ymdl.month() == m);
+ }
+ }
+
+
+ { // operator/(const year& y, const month_day_last& mdl) (and switched)
+ ASSERT_NOEXCEPT ( year{2018}/month_day_last{February});
+ ASSERT_SAME_TYPE(year_month_day_last, decltype(year{2018}/month_day_last{February}));
+ ASSERT_NOEXCEPT ( month_day_last{February}/year{2018});
+ ASSERT_SAME_TYPE(year_month_day_last, decltype(month_day_last{February}/year{2018}));
+
+ static_assert((year{2018}/month_day_last{February}).month() == February, "");
+ static_assert((year{2018}/month_day_last{February}).year() == year{2018}, "");
+ static_assert((month_day_last{February}/year{2018}).month() == February, "");
+ static_assert((month_day_last{February}/year{2018}).year() == year{2018}, "");
+
+ for (int i = 1000; i < 1010; ++i)
+ for (unsigned j = 1; j <= 12; ++j)
+ {
+ year y{i};
+ month m{j};
+ year_month_day_last ymdl1 = y/month_day_last{m};
+ year_month_day_last ymdl2 = month_day_last{m}/y;
+ assert(ymdl1.month() == m);
+ assert(ymdl2.month() == m);
+ assert(ymdl2.year() == y);
+ assert(ymdl1.year() == y);
+ assert(ymdl1 == ymdl2);
+ }
+ }
+
+ { // operator/(int y, const month_day_last& mdl) (and switched)
+ ASSERT_NOEXCEPT ( 2018/month_day_last{February});
+ ASSERT_SAME_TYPE(year_month_day_last, decltype(2018/month_day_last{February}));
+ ASSERT_NOEXCEPT ( month_day_last{February}/2018);
+ ASSERT_SAME_TYPE(year_month_day_last, decltype(month_day_last{February}/2018));
+
+ static_assert((2018/month_day_last{February}).month() == February, "");
+ static_assert((2018/month_day_last{February}).year() == year{2018}, "");
+ static_assert((month_day_last{February}/2018).month() == February, "");
+ static_assert((month_day_last{February}/2018).year() == year{2018}, "");
+
+ for (int i = 1000; i < 1010; ++i)
+ for (unsigned j = 1; j <= 12; ++j)
+ {
+ year y{i};
+ month m{j};
+ year_month_day_last ymdl1 = i/month_day_last{m};
+ year_month_day_last ymdl2 = month_day_last{m}/i;
+ assert(ymdl1.month() == m);
+ assert(ymdl2.month() == m);
+ assert(ymdl2.year() == y);
+ assert(ymdl1.year() == y);
+ assert(ymdl1 == ymdl2);
+ }
+ }
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class year_month_weekday;
+
+// constexpr year_month_weekday
+// operator/(const year_month& ym, const weekday_indexed& wdi) noexcept;
+// Returns: {ym.year(), ym.month(), wdi}.
+//
+// constexpr year_month_weekday
+// operator/(const year& y, const month_weekday& mwd) noexcept;
+// Returns: {y, mwd.month(), mwd.weekday_indexed()}.
+//
+// constexpr year_month_weekday
+// operator/(int y, const month_weekday& mwd) noexcept;
+// Returns: year(y) / mwd.
+//
+// constexpr year_month_weekday
+// operator/(const month_weekday& mwd, const year& y) noexcept;
+// Returns: y / mwd.
+//
+// constexpr year_month_weekday
+// operator/(const month_weekday& mwd, int y) noexcept;
+// Returns: year(y) / mwd.
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+#include "test_comparisons.h"
+
+int main()
+{
+ using year = std::chrono::year;
+ using year_month = std::chrono::year_month;
+ using month_weekday = std::chrono::month_weekday;
+ using year_month_weekday = std::chrono::year_month_weekday;
+ using month = std::chrono::month;
+ using weekday = std::chrono::weekday;
+ using weekday = std::chrono::weekday;
+ using weekday_indexed = std::chrono::weekday_indexed;
+
+ constexpr weekday Tuesday = std::chrono::Tuesday;
+ constexpr month February = std::chrono::February;
+
+
+ { // operator/(const year_month& ym, const weekday_indexed& wdi)
+ constexpr year_month Feb2018{year{2018}, February};
+
+ ASSERT_NOEXCEPT ( Feb2018/weekday_indexed{Tuesday, 2});
+ ASSERT_SAME_TYPE(year_month_weekday, decltype(Feb2018/weekday_indexed{Tuesday, 2}));
+
+ static_assert((Feb2018/weekday_indexed{Tuesday, 2}).year() == year{2018}, "" );
+ static_assert((Feb2018/weekday_indexed{Tuesday, 2}).month() == February, "" );
+ static_assert((Feb2018/weekday_indexed{Tuesday, 2}).weekday() == Tuesday, "" );
+
+ for (int i = 1000; i < 1010; ++i)
+ for (int j = 1; j <= 12; ++j)
+ for (unsigned k = 0; k <= 6; ++k)
+ for (unsigned l = 1; l <= 5; ++l)
+ {
+ year y(i);
+ month m(j);
+ weekday wd{k};
+ year_month_weekday ymd = year_month{y,m}/weekday_indexed{wd,l};
+ assert(ymd.year() == y);
+ assert(ymd.month() == m);
+ assert(ymd.weekday() == wd);
+ }
+ }
+
+ { // operator/(const year& y, const month_weekday& mwd) (and switched)
+ constexpr month_weekday Feb1stTues{February, weekday_indexed{Tuesday, 1}};
+ ASSERT_NOEXCEPT ( year{2018}/Feb1stTues);
+ ASSERT_SAME_TYPE(year_month_weekday, decltype(year{2018}/Feb1stTues));
+ ASSERT_NOEXCEPT ( Feb1stTues/year{2018});
+ ASSERT_SAME_TYPE(year_month_weekday, decltype(Feb1stTues/year{2018}));
+
+ static_assert((year{2018}/Feb1stTues).year() == year{2018}, "" );
+ static_assert((year{2018}/Feb1stTues).month() == February, "" );
+ static_assert((year{2018}/Feb1stTues).weekday() == Tuesday, "" );
+
+ for (int i = 1000; i < 1010; ++i)
+ for (int j = 1; j <= 12; ++j)
+ for (unsigned k = 0; k <= 6; ++k)
+ for (unsigned l = 1; l <= 5; ++l)
+ {
+ year y(i);
+ month m(j);
+ weekday wd{k};
+ month_weekday mwd{m, weekday_indexed{weekday{k}, l}};
+ year_month_weekday ymd1 = y/mwd;
+ year_month_weekday ymd2 = mwd/y;
+ assert(ymd1.year() == y);
+ assert(ymd2.year() == y);
+ assert(ymd1.month() == m);
+ assert(ymd2.month() == m);
+ assert(ymd1.weekday() == wd);
+ assert(ymd2.weekday() == wd);
+ assert(ymd1 == ymd2);
+ }
+ }
+
+
+ { // operator/(int y, const month_weekday& mwd) (and switched)
+ constexpr month_weekday Feb1stTues{February, weekday_indexed{Tuesday, 1}};
+ ASSERT_NOEXCEPT ( 2018/Feb1stTues);
+ ASSERT_SAME_TYPE(year_month_weekday, decltype(2018/Feb1stTues));
+ ASSERT_NOEXCEPT ( Feb1stTues/2018);
+ ASSERT_SAME_TYPE(year_month_weekday, decltype(Feb1stTues/2018));
+
+ static_assert((2018/Feb1stTues).year() == year{2018}, "" );
+ static_assert((2018/Feb1stTues).month() == February, "" );
+ static_assert((2018/Feb1stTues).weekday() == Tuesday, "" );
+
+ for (int i = 1000; i < 1010; ++i)
+ for (int j = 1; j <= 12; ++j)
+ for (unsigned k = 0; k <= 6; ++k)
+ for (unsigned l = 1; l <= 5; ++l)
+ {
+ year y(i);
+ month m(j);
+ weekday wd{k};
+ month_weekday mwd{m, weekday_indexed{weekday{k}, l}};
+ year_month_weekday ymd1 = i/mwd;
+ year_month_weekday ymd2 = mwd/i;
+ assert(ymd1.year() == y);
+ assert(ymd2.year() == y);
+ assert(ymd1.month() == m);
+ assert(ymd2.month() == m);
+ assert(ymd1.weekday() == wd);
+ assert(ymd2.weekday() == wd);
+ assert(ymd1 == ymd2);
+ }
+ }
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class year_month_weekday_last;
+
+// constexpr year_month_weekday_last
+// operator/(const year_month& ym, const weekday_last& wdl) noexcept;
+// Returns: {ym.year(), ym.month(), wdl}.
+//
+// constexpr year_month_weekday_last
+// operator/(const year& y, const month_weekday_last& mwdl) noexcept;
+// Returns: {y, mwdl.month(), mwdl.weekday_last()}.
+//
+// constexpr year_month_weekday_last
+// operator/(int y, const month_weekday_last& mwdl) noexcept;
+// Returns: year(y) / mwdl.
+//
+// constexpr year_month_weekday_last
+// operator/(const month_weekday_last& mwdl, const year& y) noexcept;
+// Returns: y / mwdl.
+//
+// constexpr year_month_weekday_last
+// operator/(const month_weekday_last& mwdl, int y) noexcept;
+// Returns: year(y) / mwdl.
+
+
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+#include "test_comparisons.h"
+
+int main()
+{
+ using year_month = std::chrono::year_month;
+ using month_weekday = std::chrono::month_weekday;
+ using year = std::chrono::year;
+ using month = std::chrono::month;
+ using weekday = std::chrono::weekday;
+ using weekday_last = std::chrono::weekday_last;
+ using month_weekday_last = std::chrono::month_weekday_last;
+ using year_month_weekday_last = std::chrono::year_month_weekday_last;
+
+ constexpr weekday Tuesday = std::chrono::Tuesday;
+ constexpr month February = std::chrono::February;
+
+ { // operator/(const year_month& ym, const weekday_last& wdl) (and switched)
+ constexpr year_month Feb2018{year{2018}, February};
+
+ ASSERT_NOEXCEPT ( Feb2018/weekday_last{Tuesday});
+ ASSERT_SAME_TYPE(year_month_weekday_last, decltype(Feb2018/weekday_last{Tuesday}));
+
+ static_assert((Feb2018/weekday_last{Tuesday}).year() == year{2018}, "");
+ static_assert((Feb2018/weekday_last{Tuesday}).month() == February, "");
+ static_assert((Feb2018/weekday_last{Tuesday}).weekday() == Tuesday, "");
+
+ for (int i = 1000; i < 1010; ++i)
+ for (unsigned j = 1; j <= 12; ++j)
+ for (unsigned k = 0; k <= 6; ++k)
+ {
+ year y{i};
+ month m{j};
+ weekday wd{k};
+ year_month_weekday_last ymwdl = year_month{y,m}/weekday_last{wd};
+ assert(ymwdl.year() == y);
+ assert(ymwdl.month() == m);
+ assert(ymwdl.weekday() == wd);
+ }
+ }
+
+
+ { // operator/(const year& y, const month_weekday_last& mwdl) (and switched)
+ constexpr month_weekday_last FebLastTues{February, weekday_last{Tuesday}};
+
+ ASSERT_NOEXCEPT ( year{2018}/FebLastTues);
+ ASSERT_SAME_TYPE(year_month_weekday_last, decltype(year{2018}/FebLastTues));
+ ASSERT_NOEXCEPT ( FebLastTues/year{2018});
+ ASSERT_SAME_TYPE(year_month_weekday_last, decltype(FebLastTues/year{2018}));
+
+
+ static_assert((year{2018}/FebLastTues).year() == year{2018}, "");
+ static_assert((year{2018}/FebLastTues).month() == February, "");
+ static_assert((year{2018}/FebLastTues).weekday() == Tuesday, "");
+ static_assert((FebLastTues/year{2018}).year() == year{2018}, "");
+ static_assert((FebLastTues/year{2018}).month() == February, "");
+ static_assert((FebLastTues/year{2018}).weekday() == Tuesday, "");
+
+
+ for (int i = 1000; i < 1010; ++i)
+ for (unsigned j = 1; j <= 12; ++j)
+ for (unsigned k = 0; k <= 6; ++k)
+ {
+ year y{i};
+ month m{j};
+ weekday wd{k};
+ year_month_weekday_last ymwdl1 = y/month_weekday_last{m, weekday_last{wd}};
+ year_month_weekday_last ymwdl2 = month_weekday_last{m, weekday_last{wd}}/y;
+ assert(ymwdl1.year() == y);
+ assert(ymwdl2.year() == y);
+ assert(ymwdl1.month() == m);
+ assert(ymwdl2.month() == m);
+ assert(ymwdl1.weekday() == wd);
+ assert(ymwdl2.weekday() == wd);
+ assert(ymwdl1 == ymwdl2);
+ }
+ }
+
+
+ { // operator/(int y, const month_weekday_last& mwdl) (and switched)
+ constexpr month_weekday_last FebLastTues{February, weekday_last{Tuesday}};
+
+ ASSERT_NOEXCEPT ( 2018/FebLastTues);
+ ASSERT_SAME_TYPE(year_month_weekday_last, decltype(2018/FebLastTues));
+ ASSERT_NOEXCEPT ( FebLastTues/2018);
+ ASSERT_SAME_TYPE(year_month_weekday_last, decltype(FebLastTues/2018));
+
+
+ static_assert((2018/FebLastTues).year() == year{2018}, "");
+ static_assert((2018/FebLastTues).month() == February, "");
+ static_assert((2018/FebLastTues).weekday() == Tuesday, "");
+ static_assert((FebLastTues/2018).year() == year{2018}, "");
+ static_assert((FebLastTues/2018).month() == February, "");
+ static_assert((FebLastTues/2018).weekday() == Tuesday, "");
+
+
+ for (int i = 1000; i < 1010; ++i)
+ for (unsigned j = 1; j <= 12; ++j)
+ for (unsigned k = 0; k <= 6; ++k)
+ {
+ year y{i};
+ month m{j};
+ weekday wd{k};
+ year_month_weekday_last ymwdl1 = i/month_weekday_last{m, weekday_last{wd}};
+ year_month_weekday_last ymwdl2 = month_weekday_last{m, weekday_last{wd}}/i;
+ assert(ymwdl1.year() == y);
+ assert(ymwdl2.year() == y);
+ assert(ymwdl1.month() == m);
+ assert(ymwdl2.month() == m);
+ assert(ymwdl1.weekday() == wd);
+ assert(ymwdl2.weekday() == wd);
+ assert(ymwdl1 == ymwdl2);
+ }
+ }
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class weekday_indexed;
+
+// weekday_indexed() = default;
+// constexpr weekday_indexed(const chrono::weekday& wd, unsigned index) noexcept;
+//
+// Effects: Constructs an object of type weekday_indexed by initializing wd_ with wd and index_ with index.
+// The values held are unspecified if !wd.ok() or index is not in the range [1, 5].
+//
+// constexpr chrono::weekday weekday() const noexcept;
+// constexpr unsigned index() const noexcept;
+// constexpr bool ok() const noexcept;
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+ using weekday = std::chrono::weekday;
+ using weekday_indexed = std::chrono::weekday_indexed;
+
+ ASSERT_NOEXCEPT(weekday_indexed{});
+ ASSERT_NOEXCEPT(weekday_indexed(weekday{1}, 1));
+
+ constexpr weekday_indexed wdi0{};
+ static_assert( wdi0.weekday() == weekday{}, "");
+ static_assert( wdi0.index() == 0, "");
+ static_assert(!wdi0.ok(), "");
+
+ constexpr weekday_indexed wdi1{std::chrono::Sunday, 2};
+ static_assert( wdi1.weekday() == std::chrono::Sunday, "");
+ static_assert( wdi1.index() == 2, "");
+ static_assert( wdi1.ok(), "");
+
+ for (unsigned i = 1; i <= 5; ++i)
+ {
+ weekday_indexed wdi(std::chrono::Tuesday, i);
+ assert( wdi.weekday() == std::chrono::Tuesday);
+ assert( wdi.index() == i);
+ assert( wdi.ok());
+ }
+
+ for (unsigned i = 6; i <= 20; ++i)
+ {
+ weekday_indexed wdi(std::chrono::Tuesday, i);
+ assert(!wdi.ok());
+ }
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class weekday_indexed;
+
+// constexpr unsigned index() const noexcept;
+// Returns: index_
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+ using weekday = std::chrono::weekday;
+ using weekday_indexed = std::chrono::weekday_indexed;
+
+ ASSERT_NOEXCEPT( std::declval<const weekday_indexed>().index());
+ ASSERT_SAME_TYPE(unsigned, decltype(std::declval<const weekday_indexed>().index()));
+
+ static_assert( weekday_indexed{}.index() == 0, "");
+
+ for (unsigned i = 1; i <= 5; ++i)
+ {
+ weekday_indexed wdi(weekday{2}, i);
+ assert( static_cast<unsigned>(wdi.index()) == i);
+ }
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class weekday_indexed;
+
+// constexpr bool ok() const noexcept;
+// Returns: wd_.ok() && 1 <= index_ && index_ <= 5
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+ using weekday = std::chrono::weekday;
+ using weekday_indexed = std::chrono::weekday_indexed;
+
+ ASSERT_NOEXCEPT( std::declval<const weekday_indexed>().ok());
+ ASSERT_SAME_TYPE(bool, decltype(std::declval<const weekday_indexed>().ok()));
+
+ static_assert(!weekday_indexed{}.ok(), "");
+ static_assert( weekday_indexed{std::chrono::Sunday, 2}.ok(), "");
+
+ assert(!(weekday_indexed(std::chrono::Tuesday, 0).ok()));
+ for (unsigned i = 1; i <= 5; ++i)
+ {
+ weekday_indexed wdi(std::chrono::Tuesday, i);
+ assert( wdi.ok());
+ }
+
+ for (unsigned i = 6; i <= 20; ++i)
+ {
+ weekday_indexed wdi(std::chrono::Tuesday, i);
+ assert(!wdi.ok());
+ }
+
+// Not a valid weekday
+ assert(!(weekday_indexed(weekday{9U}, 1).ok()));
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class weekday_indexed;
+
+// constexpr chrono::weekday weekday() const noexcept;
+// Returns: wd_
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+ using weekday = std::chrono::weekday;
+ using weekday_indexed = std::chrono::weekday_indexed;
+
+ ASSERT_NOEXCEPT( std::declval<const weekday_indexed>().weekday());
+ ASSERT_SAME_TYPE(std::chrono::weekday, decltype(std::declval<const weekday_indexed>().weekday()));
+
+ static_assert( weekday_indexed{}.weekday() == weekday{}, "");
+ static_assert( weekday_indexed{std::chrono::Tuesday, 0}.weekday() == std::chrono::Tuesday, "");
+
+ for (unsigned i = 0; i <= 6; ++i)
+ {
+ weekday_indexed wdi(weekday{i}, 2);
+ assert( static_cast<unsigned>(wdi.weekday()) == i);
+ }
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class weekday_indexed;
+
+// constexpr bool operator==(const weekday_indexed& x, const weekday_indexed& y) noexcept;
+// Returns: x.weekday() == y.weekday() && x.index() == y.index().
+// constexpr bool operator!=(const weekday_indexed& x, const weekday_indexed& y) noexcept;
+// Returns: !(x == y)
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+#include "test_comparisons.h"
+
+int main()
+{
+ using weekday = std::chrono::weekday;
+ using weekday_indexed = std::chrono::weekday_indexed;
+
+ AssertComparisons2AreNoexcept<weekday_indexed>();
+ AssertComparisons2ReturnBool<weekday_indexed>();
+
+ static_assert( (weekday_indexed{} == weekday_indexed{}), "");
+ static_assert(!(weekday_indexed{} != weekday_indexed{}), "");
+
+ static_assert(!(weekday_indexed{} == weekday_indexed{std::chrono::Tuesday, 1}), "");
+ static_assert( (weekday_indexed{} != weekday_indexed{std::chrono::Tuesday, 1}), "");
+
+// Some 'ok' values as well
+ static_assert( (weekday_indexed{weekday{1}, 2} == weekday_indexed{weekday{1}, 2}), "");
+ static_assert(!(weekday_indexed{weekday{1}, 2} != weekday_indexed{weekday{1}, 2}), "");
+
+ static_assert(!(weekday_indexed{weekday{1}, 2} == weekday_indexed{weekday{1}, 1}), "");
+ static_assert( (weekday_indexed{weekday{1}, 2} != weekday_indexed{weekday{1}, 1}), "");
+ static_assert(!(weekday_indexed{weekday{1}, 2} == weekday_indexed{weekday{2}, 2}), "");
+ static_assert( (weekday_indexed{weekday{1}, 2} != weekday_indexed{weekday{2}, 2}), "");
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+// XFAIL: *
+
+// <chrono>
+// class weekday_indexed;
+
+// template<class charT, class traits>
+// basic_ostream<charT, traits>&
+// operator<<(basic_ostream<charT, traits>& os, const weekday_indexed& wdi);
+//
+// Effects: os << wdi.weekday() << '[' << wdi.index().
+// If wdi.index() is in the range [1, 5], appends with ']',
+// otherwise appends with " is not a valid index]".
+
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+ using weekday_indexed = std::chrono::weekday_indexed;
+ using weekday = std::chrono::weekday;
+
+ std::cout << weekday_indexed{weekday{3}};
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class weekday_indexed;
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+ using weekday_indexed = std::chrono::weekday_indexed;
+
+ static_assert(std::is_trivially_copyable_v<weekday_indexed>, "");
+ static_assert(std::is_standard_layout_v<weekday_indexed>, "");
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class weekday_last;
+
+// explicit constexpr weekday_last(const chrono::weekday& wd) noexcept;
+//
+// Effects: Constructs an object of type weekday_last by initializing wd_ with wd.
+//
+// constexpr chrono::weekday weekday() const noexcept;
+// constexpr bool ok() const noexcept;
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+ using weekday = std::chrono::weekday;
+ using weekday_last = std::chrono::weekday_last;
+
+ ASSERT_NOEXCEPT(weekday_last{weekday{}});
+
+ constexpr weekday_last wdl0{weekday{}};
+ static_assert( wdl0.weekday() == weekday{}, "");
+ static_assert( wdl0.ok(), "");
+
+ constexpr weekday_last wdl1 {weekday{1}};
+ static_assert( wdl1.weekday() == weekday{1}, "");
+ static_assert( wdl1.ok(), "");
+
+ for (unsigned i = 0; i <= 255; ++i)
+ {
+ weekday_last wdl{weekday{i}};
+ assert(wdl.weekday() == weekday{i});
+ }
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class weekday_last;
+
+// constexpr bool ok() const noexcept;
+// Returns: wd_.ok()
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+ using weekday = std::chrono::weekday;
+ using weekday_last = std::chrono::weekday_last;
+
+ ASSERT_NOEXCEPT( std::declval<const weekday_last>().ok());
+ ASSERT_SAME_TYPE(bool, decltype(std::declval<const weekday_last>().ok()));
+
+ static_assert( weekday_last{weekday{0}}.ok(), "");
+ static_assert( weekday_last{weekday{1}}.ok(), "");
+ static_assert(!weekday_last{weekday{7}}.ok(), "");
+
+ for (unsigned i = 0; i <= 255; ++i)
+ assert(weekday_last{weekday{i}}.ok() == weekday{i}.ok());
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class weekday_last;
+
+// constexpr chrono::weekday weekday() const noexcept;
+// Returns: wd_
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+ using weekday = std::chrono::weekday;
+ using weekday_last = std::chrono::weekday_last;
+
+ ASSERT_NOEXCEPT( std::declval<const weekday_last>().weekday());
+ ASSERT_SAME_TYPE(weekday, decltype(std::declval<const weekday_last>().weekday()));
+
+ for (unsigned i = 0; i <= 255; ++i)
+ assert(weekday_last{weekday{i}}.weekday() == weekday{i});
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class weekday_last;
+
+// constexpr bool operator==(const weekday& x, const weekday& y) noexcept;
+// constexpr bool operator!=(const weekday& x, const weekday& y) noexcept;
+
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+#include "test_comparisons.h"
+
+int main()
+{
+ using weekday = std::chrono::weekday;
+ using weekday_last = std::chrono::weekday_last;
+
+ AssertComparisons2AreNoexcept<weekday_last>();
+ AssertComparisons2ReturnBool<weekday_last>();
+
+ static_assert(testComparisons2Values<weekday_last>(weekday{0}, weekday{0}), "");
+ static_assert(testComparisons2Values<weekday_last>(weekday{0}, weekday{1}), "");
+
+// Some 'ok' values as well
+ static_assert(testComparisons2Values<weekday_last>(weekday{2}, weekday{2}), "");
+ static_assert(testComparisons2Values<weekday_last>(weekday{2}, weekday{3}), "");
+
+ for (unsigned i = 0; i < 6; ++i)
+ for (unsigned j = 0; j < 6; ++j)
+ assert(testComparisons2Values<weekday_last>(weekday{i}, weekday{j}));
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+// XFAIL: *
+
+// <chrono>
+// class weekday_last;
+
+// template<class charT, class traits>
+// basic_ostream<charT, traits>&
+// operator<<(basic_ostream<charT, traits>& os, const weekday_last& wdl);
+//
+// Returns: os << wdl.weekday() << "[last]".
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+#include <iostream>
+
+#include "test_macros.h"
+
+int main()
+{
+ using weekday_last = std::chrono::weekday_last;
+ using weekday = std::chrono::weekday;
+
+ std::cout << weekday_last{weekday{3}};
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class weekday_last;
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+ using weekday_last = std::chrono::weekday_last;
+
+ static_assert(std::is_trivially_copyable_v<weekday_last>, "");
+ static_assert(std::is_standard_layout_v<weekday_last>, "");
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class weekday;
+
+// weekday() = default;
+// explicit constexpr weekday(unsigned wd) noexcept;
+// constexpr weekday(const sys_days& dp) noexcept;
+// explicit constexpr weekday(const local_days& dp) noexcept;
+//
+// explicit constexpr operator unsigned() const noexcept;
+
+// Effects: Constructs an object of type weekday by initializing m_ with m.
+// The value held is unspecified if d is not in the range [0, 255].
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+ using weekday = std::chrono::weekday;
+
+ ASSERT_NOEXCEPT(weekday{});
+ ASSERT_NOEXCEPT(weekday(1));
+ ASSERT_NOEXCEPT(static_cast<unsigned>(weekday(1)));
+
+ constexpr weekday m0{};
+ static_assert(static_cast<unsigned>(m0) == 0, "");
+
+ constexpr weekday m1{1};
+ static_assert(static_cast<unsigned>(m1) == 1, "");
+
+ for (unsigned i = 0; i <= 255; ++i)
+ {
+ weekday m(i);
+ assert(static_cast<unsigned>(m) == i);
+ }
+
+// TODO - sys_days and local_days ctor tests
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class weekday;
+
+// constexpr weekday& operator--() noexcept;
+// constexpr weekday operator--(int) noexcept;
+
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+#include "../../euclidian.h"
+
+template <typename WD>
+constexpr bool testConstexpr()
+{
+ WD wd{1};
+ if (static_cast<unsigned>(--wd) != 0) return false;
+ if (static_cast<unsigned>(wd--) != 0) return false;
+ if (static_cast<unsigned>(wd) != 6) return false;
+ return true;
+}
+
+int main()
+{
+ using weekday = std::chrono::weekday;
+ ASSERT_NOEXCEPT(--(std::declval<weekday&>()) );
+ ASSERT_NOEXCEPT( (std::declval<weekday&>())--);
+
+ ASSERT_SAME_TYPE(weekday , decltype( std::declval<weekday&>()--));
+ ASSERT_SAME_TYPE(weekday&, decltype(--std::declval<weekday&>() ));
+
+ static_assert(testConstexpr<weekday>(), "");
+
+ for (unsigned i = 0; i <= 6; ++i)
+ {
+ weekday wd(i);
+ assert((static_cast<unsigned>(--wd) == euclidian_subtraction<unsigned, 0, 6>(i, 1)));
+ assert((static_cast<unsigned>(wd--) == euclidian_subtraction<unsigned, 0, 6>(i, 1)));
+ assert((static_cast<unsigned>(wd) == euclidian_subtraction<unsigned, 0, 6>(i, 2)));
+ }
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class weekday;
+
+// constexpr weekday& operator++() noexcept;
+// constexpr weekday operator++(int) noexcept;
+
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+#include "../../euclidian.h"
+
+template <typename WD>
+constexpr bool testConstexpr()
+{
+ WD wd{5};
+ if (static_cast<unsigned>(++wd) != 6) return false;
+ if (static_cast<unsigned>(wd++) != 6) return false;
+ if (static_cast<unsigned>(wd) != 0) return false;
+ return true;
+}
+
+int main()
+{
+ using weekday = std::chrono::weekday;
+ ASSERT_NOEXCEPT(++(std::declval<weekday&>()) );
+ ASSERT_NOEXCEPT( (std::declval<weekday&>())++);
+
+ ASSERT_SAME_TYPE(weekday , decltype( std::declval<weekday&>()++));
+ ASSERT_SAME_TYPE(weekday&, decltype(++std::declval<weekday&>() ));
+
+ static_assert(testConstexpr<weekday>(), "");
+
+ for (unsigned i = 0; i <= 6; ++i)
+ {
+ weekday wd(i);
+ assert((static_cast<unsigned>(++wd) == euclidian_addition<unsigned, 0, 6>(i, 1)));
+ assert((static_cast<unsigned>(wd++) == euclidian_addition<unsigned, 0, 6>(i, 1)));
+ assert((static_cast<unsigned>(wd) == euclidian_addition<unsigned, 0, 6>(i, 2)));
+ }
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class weekday;
+
+// constexpr bool ok() const noexcept;
+// Returns: wd_ <= 6
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+ using weekday = std::chrono::weekday;
+
+ ASSERT_NOEXCEPT( std::declval<const weekday>().ok());
+ ASSERT_SAME_TYPE(bool, decltype(std::declval<const weekday>().ok()));
+
+ static_assert( weekday{0}.ok(), "");
+ static_assert( weekday{1}.ok(), "");
+ static_assert(!weekday{7}.ok(), "");
+
+ for (unsigned i = 0; i <= 6; ++i)
+ assert(weekday{i}.ok());
+ for (unsigned i = 7; i <= 255; ++i)
+ assert(!weekday{i}.ok());
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class weekday;
+
+// constexpr weekday_indexed operator[](unsigned index) const noexcept;
+// constexpr weekday_last operator[](last_spec) const noexcept;
+
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+#include "../../euclidian.h"
+
+int main()
+{
+ using weekday = std::chrono::weekday;
+ using weekday_last = std::chrono::weekday_last;
+ using weekday_indexed = std::chrono::weekday_indexed;
+
+ constexpr weekday Sunday = std::chrono::Sunday;
+
+ ASSERT_NOEXCEPT( std::declval<weekday>()[1U]);
+ ASSERT_SAME_TYPE(weekday_indexed, decltype(std::declval<weekday>()[1U]));
+
+ ASSERT_NOEXCEPT( std::declval<weekday>()[std::chrono::last]);
+ ASSERT_SAME_TYPE(weekday_last, decltype(std::declval<weekday>()[std::chrono::last]));
+
+ static_assert(Sunday[2].weekday() == Sunday, "");
+ static_assert(Sunday[2].index () == 2, "");
+
+ for (unsigned i = 0; i <= 6; ++i)
+ {
+ weekday wd(i);
+ weekday_last wdl = wd[std::chrono::last];
+ assert(wdl.weekday() == wd);
+ assert(wdl.ok());
+ }
+
+ for (unsigned i = 0; i <= 6; ++i)
+ for (unsigned j = 1; j <= 5; ++j)
+ {
+ weekday wd(i);
+ weekday_indexed wdi = wd[j];
+ assert(wdi.weekday() == wd);
+ assert(wdi.index() == j);
+ assert(wdi.ok());
+ }
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class weekday;
+
+// constexpr weekday& operator+=(const days& d) noexcept;
+// constexpr weekday& operator-=(const days& d) noexcept;
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+#include "../../euclidian.h"
+
+template <typename M, typename Ms>
+constexpr bool testConstexpr()
+{
+ M m1{1};
+ if (static_cast<unsigned>(m1 += Ms{ 1}) != 2) return false;
+ if (static_cast<unsigned>(m1 += Ms{ 2}) != 4) return false;
+ if (static_cast<unsigned>(m1 += Ms{ 4}) != 1) return false;
+ if (static_cast<unsigned>(m1 -= Ms{ 1}) != 0) return false;
+ if (static_cast<unsigned>(m1 -= Ms{ 2}) != 5) return false;
+ if (static_cast<unsigned>(m1 -= Ms{ 4}) != 1) return false;
+ return true;
+}
+
+int main()
+{
+ using weekday = std::chrono::weekday;
+ using days = std::chrono::days;
+
+ ASSERT_NOEXCEPT( std::declval<weekday&>() += std::declval<days&>());
+ ASSERT_SAME_TYPE(weekday&, decltype(std::declval<weekday&>() += std::declval<days&>()));
+
+ ASSERT_NOEXCEPT( std::declval<weekday&>() -= std::declval<days&>());
+ ASSERT_SAME_TYPE(weekday&, decltype(std::declval<weekday&>() -= std::declval<days&>()));
+
+ static_assert(testConstexpr<weekday, days>(), "");
+
+ for (unsigned i = 0; i <= 6; ++i)
+ {
+ weekday wd(i);
+ assert((static_cast<unsigned>(wd += days{3}) == euclidian_addition<unsigned, 0, 6>(i, 3)));
+ assert((static_cast<unsigned>(wd) == euclidian_addition<unsigned, 0, 6>(i, 3)));
+ }
+
+ for (unsigned i = 0; i <= 6; ++i)
+ {
+ weekday wd(i);
+ assert((static_cast<unsigned>(wd -= days{4}) == euclidian_subtraction<unsigned, 0, 6>(i, 4)));
+ assert((static_cast<unsigned>(wd) == euclidian_subtraction<unsigned, 0, 6>(i, 4)));
+ }
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class weekday;
+
+// constexpr bool operator==(const weekday& x, const weekday& y) noexcept;
+// constexpr bool operator!=(const weekday& x, const weekday& y) noexcept;
+
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+#include "test_comparisons.h"
+
+int main()
+{
+ using weekday = std::chrono::weekday;
+
+ AssertComparisons2AreNoexcept<weekday>();
+ AssertComparisons2ReturnBool<weekday>();
+
+ static_assert(testComparisons2Values<weekday>(0U ,0U), "");
+ static_assert(testComparisons2Values<weekday>(0U, 1U), "");
+
+// Some 'ok' values as well
+ static_assert(testComparisons2Values<weekday>(5U, 5U), "");
+ static_assert(testComparisons2Values<weekday>(5U, 2U), "");
+
+ for (unsigned i = 0; i < 6; ++i)
+ for (unsigned j = 0; j < 6; ++j)
+ assert(testComparisons2Values<weekday>(i, j));
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+
+// 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};
+
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+
+ ASSERT_SAME_TYPE(const std::chrono::weekday, decltype(std::chrono::Sunday));
+ ASSERT_SAME_TYPE(const std::chrono::weekday, decltype(std::chrono::Monday));
+ ASSERT_SAME_TYPE(const std::chrono::weekday, decltype(std::chrono::Tuesday));
+ ASSERT_SAME_TYPE(const std::chrono::weekday, decltype(std::chrono::Wednesday));
+ ASSERT_SAME_TYPE(const std::chrono::weekday, decltype(std::chrono::Thursday));
+ ASSERT_SAME_TYPE(const std::chrono::weekday, decltype(std::chrono::Friday));
+ ASSERT_SAME_TYPE(const std::chrono::weekday, decltype(std::chrono::Saturday));
+
+ static_assert( std::chrono::Sunday == std::chrono::weekday(0), "");
+ static_assert( std::chrono::Monday == std::chrono::weekday(1), "");
+ static_assert( std::chrono::Tuesday == std::chrono::weekday(2), "");
+ static_assert( std::chrono::Wednesday == std::chrono::weekday(3), "");
+ static_assert( std::chrono::Thursday == std::chrono::weekday(4), "");
+ static_assert( std::chrono::Friday == std::chrono::weekday(5), "");
+ static_assert( std::chrono::Saturday == std::chrono::weekday(6), "");
+
+ assert(std::chrono::Sunday == std::chrono::weekday(0));
+ assert(std::chrono::Monday == std::chrono::weekday(1));
+ assert(std::chrono::Tuesday == std::chrono::weekday(2));
+ assert(std::chrono::Wednesday == std::chrono::weekday(3));
+ assert(std::chrono::Thursday == std::chrono::weekday(4));
+ assert(std::chrono::Friday == std::chrono::weekday(5));
+ assert(std::chrono::Saturday == std::chrono::weekday(6));
+
+ assert(static_cast<unsigned>(std::chrono::Sunday) == 0);
+ assert(static_cast<unsigned>(std::chrono::Monday) == 1);
+ assert(static_cast<unsigned>(std::chrono::Tuesday) == 2);
+ assert(static_cast<unsigned>(std::chrono::Wednesday) == 3);
+ assert(static_cast<unsigned>(std::chrono::Thursday) == 4);
+ assert(static_cast<unsigned>(std::chrono::Friday) == 5);
+ assert(static_cast<unsigned>(std::chrono::Saturday) == 6);
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class weekday;
+
+// constexpr weekday operator-(const weekday& x, const days& y) noexcept;
+// Returns: x + -y.
+//
+// constexpr days operator-(const weekday& x, const weekday& y) noexcept;
+// Returns: If x.ok() == true and y.ok() == true, returns a value d in the range
+// [days{0}, days{6}] satisfying y + d == x.
+// Otherwise the value returned is unspecified.
+// [Example: Sunday - Monday == days{6}. —end example]
+
+
+extern "C" int printf(const char *, ...);
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+#include "../../euclidian.h"
+
+template <typename WD, typename Ds>
+constexpr bool testConstexpr()
+{
+ {
+ WD wd{5};
+ Ds offset{3};
+ if (wd - offset != WD{2}) return false;
+ if (wd - WD{2} != offset) return false;
+ }
+
+// Check the example
+ if (WD{0} - WD{1} != Ds{6}) return false;
+ return true;
+}
+
+int main()
+{
+ using weekday = std::chrono::weekday;
+ using days = std::chrono::days;
+
+ ASSERT_NOEXCEPT( std::declval<weekday>() - std::declval<days>());
+ ASSERT_SAME_TYPE(weekday, decltype(std::declval<weekday>() - std::declval<days>()));
+
+ ASSERT_NOEXCEPT( std::declval<weekday>() - std::declval<weekday>());
+ ASSERT_SAME_TYPE(days, decltype(std::declval<weekday>() - std::declval<weekday>()));
+
+ static_assert(testConstexpr<weekday, days>(), "");
+
+ for (unsigned i = 0; i <= 6; ++i)
+ for (unsigned j = 0; j <= 6; ++j)
+ {
+ weekday wd = weekday{i} - days{j};
+ assert(wd + days{j} == weekday{i});
+ assert((static_cast<unsigned>(wd) == euclidian_subtraction<unsigned, 0, 6>(i, j)));
+ }
+
+ for (unsigned i = 0; i <= 6; ++i)
+ for (unsigned j = 0; j <= 6; ++j)
+ {
+ days d = weekday{j} - weekday{i};
+ assert(weekday{i} + d == weekday{j});
+ }
+
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class weekday;
+
+// constexpr weekday operator+(const days& x, const weekday& y) noexcept;
+// Returns: weekday(int{x} + y.count()).
+//
+// constexpr weekday operator+(const weekday& x, const days& y) noexcept;
+// Returns:
+// weekday{modulo(static_cast<long long>(unsigned{x}) + y.count(), 7)}
+// where modulo(n, 7) computes the remainder of n divided by 7 using Euclidean division.
+// [Note: Given a divisor of 12, Euclidean division truncates towards negative infinity
+// and always produces a remainder in the range of [0, 6].
+// Assuming no overflow in the signed summation, this operation results in a weekday
+// holding a value in the range [0, 6] even if !x.ok(). —end note]
+// [Example: Monday + days{6} == Sunday. —end example]
+
+
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+#include "../../euclidian.h"
+
+template <typename M, typename Ms>
+constexpr bool testConstexpr()
+{
+ M m{1};
+ Ms offset{4};
+ if (m + offset != M{5}) return false;
+ if (offset + m != M{5}) return false;
+// Check the example
+ if (M{1} + Ms{6} != M{0}) return false;
+ return true;
+}
+
+int main()
+{
+ using weekday = std::chrono::weekday;
+ using days = std::chrono::days;
+
+ ASSERT_NOEXCEPT( std::declval<weekday>() + std::declval<days>());
+ ASSERT_SAME_TYPE(weekday, decltype(std::declval<weekday>() + std::declval<days>()));
+
+ ASSERT_NOEXCEPT( std::declval<days>() + std::declval<weekday>());
+ ASSERT_SAME_TYPE(weekday, decltype(std::declval<days>() + std::declval<weekday>()));
+
+ static_assert(testConstexpr<weekday, days>(), "");
+
+ for (unsigned i = 0; i <= 6; ++i)
+ for (unsigned j = 0; j <= 6; ++j)
+ {
+ weekday wd1 = weekday{i} + days{j};
+ weekday wd2 = days{j} + weekday{i};
+ assert(wd1 == wd2);
+ assert((static_cast<unsigned>(wd1) == euclidian_addition<unsigned, 0, 6>(i, j)));
+ assert((static_cast<unsigned>(wd2) == euclidian_addition<unsigned, 0, 6>(i, j)));
+ }
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+// XFAIL: *
+
+// <chrono>
+// class weekday;
+
+// template<class charT, class traits>
+// basic_ostream<charT, traits>&
+// operator<<(basic_ostream<charT, traits>& os, const weekday& wd);
+//
+// Effects: If wd.ok() == true inserts format(os.getloc(), fmt, wd) where fmt is "%a" widened to charT.
+// Otherwise inserts unsigned{wd} << " is not a valid weekday".
+//
+// template<class charT, class traits>
+// basic_ostream<charT, traits>&
+// to_stream(basic_ostream<charT, traits>& os, const charT* fmt, const weekday& wd);
+//
+// Effects: Streams wd into os using the format specified by the NTCTS fmt.
+// fmt encoding follows the rules specified in 25.11.
+//
+// template<class charT, class traits, class Alloc = allocator<charT>>
+// basic_istream<charT, traits>&
+// from_stream(basic_istream<charT, traits>& is, const charT* fmt,
+// weekday& wd, basic_string<charT, traits, Alloc>* abbrev = nullptr,
+// minutes* offset = nullptr);
+//
+// Effects: Attempts to parse the input stream is into the weekday wd using
+// the format flags given in the NTCTS fmt as specified in 25.12.
+// If the parse fails to decode a valid weekday, is.setstate(ios_- base::failbit)
+// shall be called and wd shall not be modified.
+// If %Z is used and successfully parsed, that value will be assigned
+// to *abbrev if abbrev is non-null.
+// If %z (or a modified variant) is used and successfully parsed,
+// that value will be assigned to *offset if offset is non-null.
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+#include <iostream>
+
+#include "test_macros.h"
+
+int main()
+{
+ using weekday = std::chrono::weekday;
+
+ std::cout << weekday{3};
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class weekday;
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+ using weekday = std::chrono::weekday;
+
+ static_assert(std::is_trivially_copyable_v<weekday>, "");
+ static_assert(std::is_standard_layout_v<weekday>, "");
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class year;
+
+// year() = default;
+// explicit constexpr year(int m) noexcept;
+// explicit constexpr operator int() const noexcept;
+
+// Effects: Constructs an object of type year by initializing y_ with y.
+// The value held is unspecified if d is not in the range [0, 255].
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+ using year = std::chrono::year;
+
+ ASSERT_NOEXCEPT(year{});
+ ASSERT_NOEXCEPT(year(0U));
+ ASSERT_NOEXCEPT(static_cast<int>(year(0U)));
+
+ constexpr year y0{};
+ static_assert(static_cast<int>(y0) == 0, "");
+
+ constexpr year y1{1};
+ static_assert(static_cast<int>(y1) == 1, "");
+
+ for (int i = 0; i <= 2550; i += 7)
+ {
+ year year(i);
+ assert(static_cast<int>(year) == i);
+ }
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class year;
+
+// constexpr year& operator--() noexcept;
+// constexpr year operator--(int) noexcept;
+
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+template <typename Y>
+constexpr bool testConstexpr()
+{
+ Y y1{10};
+ if (static_cast<int>(--y1) != 9) return false;
+ if (static_cast<int>(y1--) != 9) return false;
+ if (static_cast<int>(y1) != 8) return false;
+ return true;
+}
+
+int main()
+{
+ using year = std::chrono::year;
+ ASSERT_NOEXCEPT(--(std::declval<year&>()) );
+ ASSERT_NOEXCEPT( (std::declval<year&>())--);
+
+ ASSERT_SAME_TYPE(year , decltype( std::declval<year&>()--));
+ ASSERT_SAME_TYPE(year&, decltype(--std::declval<year&>() ));
+
+ static_assert(testConstexpr<year>(), "");
+
+ for (int i = 11000; i <= 11020; ++i)
+ {
+ year year(i);
+ assert(static_cast<int>(--year) == i - 1);
+ assert(static_cast<int>(year--) == i - 1);
+ assert(static_cast<int>(year) == i - 2);
+ }
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class year;
+
+// constexpr year& operator++() noexcept;
+// constexpr year operator++(int) noexcept;
+
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+template <typename Y>
+constexpr bool testConstexpr()
+{
+ Y y1{10};
+ if (static_cast<int>(++y1) != 11) return false;
+ if (static_cast<int>(y1++) != 11) return false;
+ if (static_cast<int>(y1) != 12) return false;
+ return true;
+}
+
+int main()
+{
+ using year = std::chrono::year;
+ ASSERT_NOEXCEPT(++(std::declval<year&>()) );
+ ASSERT_NOEXCEPT( (std::declval<year&>())++);
+
+ ASSERT_SAME_TYPE(year , decltype( std::declval<year&>()++));
+ ASSERT_SAME_TYPE(year&, decltype(++std::declval<year&>() ));
+
+ static_assert(testConstexpr<year>(), "");
+
+ for (int i = 11000; i <= 11020; ++i)
+ {
+ year year(i);
+ assert(static_cast<int>(++year) == i + 1);
+ assert(static_cast<int>(year++) == i + 1);
+ assert(static_cast<int>(year) == i + 2);
+ }
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class year;
+
+// constexpr bool is_is_leap() const noexcept;
+// y_ % 4 == 0 && (y_ % 100 != 0 || y_ % 400 == 0)
+//
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+ using year = std::chrono::year;
+
+ ASSERT_NOEXCEPT( year(1).is_leap());
+ ASSERT_SAME_TYPE(bool, decltype(year(1).is_leap()));
+
+ static_assert(!year{1}.is_leap(), "");
+ static_assert(!year{2}.is_leap(), "");
+ static_assert(!year{3}.is_leap(), "");
+ static_assert( year{4}.is_leap(), "");
+
+ assert( year{-2000}.is_leap());
+ assert( year{ -400}.is_leap());
+ assert(!year{ -300}.is_leap());
+ assert(!year{ -200}.is_leap());
+
+ assert(!year{ 200}.is_leap());
+ assert(!year{ 300}.is_leap());
+ assert( year{ 400}.is_leap());
+ assert(!year{ 1997}.is_leap());
+ assert(!year{ 1998}.is_leap());
+ assert(!year{ 1999}.is_leap());
+ assert( year{ 2000}.is_leap());
+ assert(!year{ 2001}.is_leap());
+ assert(!year{ 2002}.is_leap());
+ assert(!year{ 2003}.is_leap());
+ assert( year{ 2004}.is_leap());
+ assert(!year{ 2100}.is_leap());
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class year;
+
+// constexpr bool ok() const noexcept;
+// Returns: min() <= y_ && y_ <= max().
+//
+// static constexpr year min() noexcept;
+// Returns year{ 32767};
+// static constexpr year max() noexcept;
+// Returns year{-32767};
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+ using year = std::chrono::year;
+
+ ASSERT_NOEXCEPT( std::declval<const year>().ok());
+ ASSERT_SAME_TYPE(bool, decltype(std::declval<const year>().ok()));
+
+ ASSERT_NOEXCEPT( year::max());
+ ASSERT_SAME_TYPE(year, decltype(year::max()));
+
+ ASSERT_NOEXCEPT( year::min());
+ ASSERT_SAME_TYPE(year, decltype(year::min()));
+
+ static_assert(static_cast<int>(year::min()) == -32767, "");
+ static_assert(static_cast<int>(year::max()) == 32767, "");
+
+ assert(year{-20001}.ok());
+ assert(year{ -2000}.ok());
+ assert(year{ -1}.ok());
+ assert(year{ 0}.ok());
+ assert(year{ 1}.ok());
+ assert(year{ 2000}.ok());
+ assert(year{ 20001}.ok());
+
+ static_assert(!year{-32768}.ok(), "");
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class year;
+
+// constexpr year operator+() const noexcept;
+// constexpr year operator-() const noexcept;
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+template <typename Y>
+constexpr bool testConstexpr()
+{
+ Y y1{1};
+ if (static_cast<int>(+y1) != 1) return false;
+ if (static_cast<int>(-y1) != -1) return false;
+ return true;
+}
+
+int main()
+{
+ using year = std::chrono::year;
+ using years = std::chrono::years;
+
+ ASSERT_NOEXCEPT(+std::declval<year>());
+ ASSERT_NOEXCEPT(-std::declval<year>());
+
+ ASSERT_SAME_TYPE(year, decltype(+std::declval<year>()));
+ ASSERT_SAME_TYPE(year, decltype(-std::declval<year>()));
+
+ static_assert(testConstexpr<year>(), "");
+
+ for (int i = 10000; i <= 10020; ++i)
+ {
+ year year(i);
+ assert(static_cast<int>(+year) == i);
+ assert(static_cast<int>(-year) == -i);
+ }
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class year;
+
+// constexpr year& operator+=(const years& d) noexcept;
+// constexpr year& operator-=(const years& d) noexcept;
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+template <typename Y, typename Ys>
+constexpr bool testConstexpr()
+{
+ Y y1{1};
+ if (static_cast<int>(y1 += Ys{ 1}) != 2) return false;
+ if (static_cast<int>(y1 += Ys{ 2}) != 4) return false;
+ if (static_cast<int>(y1 += Ys{ 8}) != 12) return false;
+ if (static_cast<int>(y1 -= Ys{ 1}) != 11) return false;
+ if (static_cast<int>(y1 -= Ys{ 2}) != 9) return false;
+ if (static_cast<int>(y1 -= Ys{ 8}) != 1) return false;
+ return true;
+}
+
+int main()
+{
+ using year = std::chrono::year;
+ using years = std::chrono::years;
+
+ ASSERT_NOEXCEPT(std::declval<year&>() += std::declval<years>());
+ ASSERT_NOEXCEPT(std::declval<year&>() -= std::declval<years>());
+
+ ASSERT_SAME_TYPE(year&, decltype(std::declval<year&>() += std::declval<years>()));
+ ASSERT_SAME_TYPE(year&, decltype(std::declval<year&>() -= std::declval<years>()));
+
+ static_assert(testConstexpr<year, years>(), "");
+
+ for (int i = 10000; i <= 10020; ++i)
+ {
+ year year(i);
+ assert(static_cast<int>(year += years{10}) == i + 10);
+ assert(static_cast<int>(year) == i + 10);
+ assert(static_cast<int>(year -= years{ 9}) == i + 1);
+ assert(static_cast<int>(year) == i + 1);
+ }
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class year;
+
+// constexpr bool operator==(const year& x, const year& y) noexcept;
+// constexpr bool operator!=(const year& x, const year& y) noexcept;
+// constexpr bool operator< (const year& x, const year& y) noexcept;
+// constexpr bool operator> (const year& x, const year& y) noexcept;
+// constexpr bool operator<=(const year& x, const year& y) noexcept;
+// constexpr bool operator>=(const year& x, const year& y) noexcept;
+
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+#include "test_comparisons.h"
+
+
+int main()
+{
+ using year = std::chrono::year;
+
+ AssertComparisons6AreNoexcept<year>();
+ AssertComparisons6ReturnBool<year>();
+
+ static_assert(testComparisons6Values<year>(0,0), "");
+ static_assert(testComparisons6Values<year>(0,1), "");
+
+// Some 'ok' values as well
+ static_assert(testComparisons6Values<year>( 5, 5), "");
+ static_assert(testComparisons6Values<year>( 5,10), "");
+
+ for (int i = 1; i < 10; ++i)
+ for (int j = 1; j < 10; ++j)
+ assert(testComparisons6Values<year>(i, j));
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+// UNSUPPORTED: clang-5, clang-6
+// UNSUPPORTED: apple-clang-6, apple-clang-7, apple-clang-8, apple-clang-9
+
+// <chrono>
+// class year;
+
+// constexpr year operator""y(unsigned long long y) noexcept;
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+ using std::chrono::year;
+ year d1 = 1234y; // expected-error-re {{no matching literal operator for call to 'operator""y' {{.*}}}}
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+// UNSUPPORTED: clang-5, clang-6
+// UNSUPPORTED: apple-clang-6, apple-clang-7, apple-clang-8, apple-clang-9
+
+// <chrono>
+// class year;
+
+// constexpr year operator""y(unsigned long long y) noexcept;
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+ {
+ using namespace std::chrono;
+ ASSERT_NOEXCEPT(4y);
+
+ static_assert( 2017y == year(2017), "");
+ year y1 = 2018y;
+ assert (y1 == year(2018));
+ }
+
+ {
+ using namespace std::literals;
+ ASSERT_NOEXCEPT(4d);
+
+ static_assert( 2017y == std::chrono::year(2017), "");
+
+ std::chrono::year y1 = 2020y;
+ assert (y1 == std::chrono::year(2020));
+ }
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class year;
+
+// constexpr year operator-(const year& x, const years& y) noexcept;
+// Returns: x + -y.
+//
+// constexpr years operator-(const year& x, const year& y) noexcept;
+// Returns: If x.ok() == true and y.ok() == true, returns a value m in the range
+// [years{0}, years{11}] satisfying y + m == x.
+// Otherwise the value returned is unspecified.
+// [Example: January - February == years{11}. —end example]
+
+extern "C" int printf(const char *, ...);
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+template <typename Y, typename Ys>
+constexpr bool testConstexpr()
+{
+ Y y{2313};
+ Ys offset{1006};
+ if (y - offset != Y{1307}) return false;
+ if (y - Y{1307} != offset) return false;
+ return true;
+}
+
+int main()
+{
+ using year = std::chrono::year;
+ using years = std::chrono::years;
+
+ ASSERT_NOEXCEPT( std::declval<year>() - std::declval<years>());
+ ASSERT_SAME_TYPE(year , decltype(std::declval<year>() - std::declval<years>()));
+
+ ASSERT_NOEXCEPT( std::declval<year>() - std::declval<year>());
+ ASSERT_SAME_TYPE(years, decltype(std::declval<year>() - std::declval<year>()));
+
+ static_assert(testConstexpr<year, years>(), "");
+
+ year y{1223};
+ for (int i = 1100; i <= 1110; ++i)
+ {
+ year y1 = y - years{i};
+ years ys1 = y - year{i};
+ assert(static_cast<int>(y1) == 1223 - i);
+ assert(ys1.count() == 1223 - i);
+ }
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class year;
+
+// constexpr year operator+(const year& x, const years& y) noexcept;
+// Returns: year(int{x} + y.count()).
+//
+// constexpr year operator+(const years& x, const year& y) noexcept;
+// Returns: y + x
+
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+template <typename Y, typename Ys>
+constexpr bool testConstexpr()
+{
+ Y y{1001};
+ Ys offset{23};
+ if (y + offset != Y{1024}) return false;
+ if (offset + y != Y{1024}) return false;
+ return true;
+}
+
+int main()
+{
+ using year = std::chrono::year;
+ using years = std::chrono::years;
+
+ ASSERT_NOEXCEPT( std::declval<year>() + std::declval<years>());
+ ASSERT_SAME_TYPE(year, decltype(std::declval<year>() + std::declval<years>()));
+
+ ASSERT_NOEXCEPT( std::declval<years>() + std::declval<year>());
+ ASSERT_SAME_TYPE(year, decltype(std::declval<years>() + std::declval<year>()));
+
+ static_assert(testConstexpr<year, years>(), "");
+
+ year y{1223};
+ for (int i = 1100; i <= 1110; ++i)
+ {
+ year y1 = y + years{i};
+ year y2 = years{i} + y;
+ assert(y1 == y2);
+ assert(static_cast<int>(y1) == i + 1223);
+ assert(static_cast<int>(y2) == i + 1223);
+ }
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+// XFAIL: *
+
+// <chrono>
+// class year;
+
+// template<class charT, class traits>
+// basic_ostream<charT, traits>&
+// operator<<(basic_ostream<charT, traits>& os, const year& y);
+//
+// Effects: Inserts format(fmt, y) where fmt is "%Y" widened to charT.
+// If !y.ok(), appends with " is not a valid year".
+//
+// template<class charT, class traits>
+// basic_ostream<charT, traits>&
+// to_stream(basic_ostream<charT, traits>& os, const charT* fmt, const year& y);
+//
+// Effects: Streams y into os using the format specified by the NTCTS fmt.
+// fmt encoding follows the rules specified in 25.11.
+//
+// template<class charT, class traits, class Alloc = allocator<charT>>
+// basic_istream<charT, traits>&
+// from_stream(basic_istream<charT, traits>& is, const charT* fmt,
+// year& y, basic_string<charT, traits, Alloc>* abbrev = nullptr,
+// minutes* offset = nullptr);
+//
+// Effects: Attempts to parse the input stream is into the year y using the format flags
+// given in the NTCTS fmt as specified in 25.12. If the parse fails to decode a valid year,
+// is.setstate(ios_base::failbit) shall be called and y shall not be modified. If %Z is used
+// and successfully parsed, that value will be assigned to *abbrev if abbrev is non-null.
+// If %z (or a modified variant) is used and successfully parsed, that value will be
+// assigned to *offset if offset is non-null.
+
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+#include <iostream>
+
+#include "test_macros.h"
+
+int main()
+{
+ using year = std::chrono::year;
+
+ std::cout << year{2018};
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class year;
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+ using year = std::chrono::year;
+
+ static_assert(std::is_trivially_copyable_v<year>, "");
+ static_assert(std::is_standard_layout_v<year>, "");
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class year_month;
+
+// year_month() = default;
+// constexpr year_month(const chrono::year& y, const chrono::month& m) noexcept;
+//
+// Effects: Constructs an object of type year_month by initializing y_ with y, and m_ with m.
+//
+// constexpr chrono::year year() const noexcept;
+// constexpr chrono::month month() const noexcept;
+// constexpr bool ok() const noexcept;
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+ using year = std::chrono::year;
+ using month = std::chrono::month;
+ using year_month = std::chrono::year_month;
+
+ ASSERT_NOEXCEPT(year_month{});
+ ASSERT_NOEXCEPT(year_month{year{1}, month{1}});
+
+ constexpr year_month ym0{};
+ static_assert( ym0.year() == year{}, "");
+ static_assert( ym0.month() == month{}, "");
+ static_assert(!ym0.ok(), "");
+
+ constexpr year_month ym1{year{2018}, std::chrono::January};
+ static_assert( ym1.year() == year{2018}, "");
+ static_assert( ym1.month() == std::chrono::January, "");
+ static_assert( ym1.ok(), "");
+
+ constexpr year_month ym2{year{2018}, month{}};
+ static_assert( ym2.year() == year{2018}, "");
+ static_assert( ym2.month() == month{}, "");
+ static_assert(!ym2.ok(), "");
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class year_month;
+
+// constexpr chrono::month month() const noexcept;
+// Returns: wd_
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+ using year = std::chrono::year;
+ using month = std::chrono::month;
+ using year_month = std::chrono::year_month;
+
+ ASSERT_NOEXCEPT( std::declval<const year_month>().month());
+ ASSERT_SAME_TYPE(month, decltype(std::declval<const year_month>().month()));
+
+ static_assert( year_month{}.month() == month{}, "");
+
+ for (unsigned i = 1; i <= 50; ++i)
+ {
+ year_month ym(year{1234}, month{i});
+ assert( static_cast<unsigned>(ym.month()) == i);
+ }
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class year_month;
+
+// constexpr bool ok() const noexcept;
+// Returns: m_.ok() && y_.ok().
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+ using month = std::chrono::month;
+ using year = std::chrono::year;
+ using year_month = std::chrono::year_month;
+
+ constexpr month January = std::chrono::January;
+
+ ASSERT_NOEXCEPT( std::declval<const year_month>().ok());
+ ASSERT_SAME_TYPE(bool, decltype(std::declval<const year_month>().ok()));
+
+ static_assert(!year_month{year{-32768}, January}.ok(), ""); // Bad year
+ static_assert(!year_month{year{2019}, month{}}.ok(), ""); // Bad month
+ static_assert( year_month{year{2019}, January}.ok(), ""); // Both OK
+
+ for (unsigned i = 0; i <= 50; ++i)
+ {
+ year_month ym{year{2019}, month{i}};
+ assert( ym.ok() == month{i}.ok());
+ }
+
+ const int ymax = static_cast<int>(year::max());
+ for (int i = ymax - 100; i <= ymax + 100; ++i)
+ {
+ year_month ym{year{i}, January};
+ assert( ym.ok() == year{i}.ok());
+ }
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class year_month;
+
+// constexpr year_month& operator+=(const months& d) noexcept;
+// constexpr year_month& operator-=(const months& d) noexcept;
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+template <typename D, typename Ds>
+constexpr bool testConstexpr(D d1)
+{
+ if (static_cast<unsigned>((d1 ).month()) != 1) return false;
+ if (static_cast<unsigned>((d1 += Ds{ 1}).month()) != 2) return false;
+ if (static_cast<unsigned>((d1 += Ds{ 2}).month()) != 4) return false;
+ if (static_cast<unsigned>((d1 += Ds{12}).month()) != 4) return false;
+ if (static_cast<unsigned>((d1 -= Ds{ 1}).month()) != 3) return false;
+ if (static_cast<unsigned>((d1 -= Ds{ 2}).month()) != 1) return false;
+ if (static_cast<unsigned>((d1 -= Ds{12}).month()) != 1) return false;
+ return true;
+}
+
+int main()
+{
+ using month = std::chrono::month;
+ using months = std::chrono::months;
+ using year = std::chrono::year;
+ using year_month = std::chrono::year_month;
+
+ ASSERT_NOEXCEPT( std::declval<year_month&>() += std::declval<months>());
+ ASSERT_SAME_TYPE(year_month&, decltype(std::declval<year_month&>() += std::declval<months>()));
+
+ ASSERT_NOEXCEPT( std::declval<year_month&>() -= std::declval<months>());
+ ASSERT_SAME_TYPE(year_month&, decltype(std::declval<year_month&>() -= std::declval<months>()));
+
+ static_assert(testConstexpr<year_month, months>(year_month{year{1234}, month{1}}), "");
+
+ for (unsigned i = 0; i <= 10; ++i)
+ {
+ year y{1234};
+ year_month ym(y, month{i});
+ assert(static_cast<unsigned>((ym += months{2}).month()) == i + 2);
+ assert(ym.year() == y);
+ assert(static_cast<unsigned>((ym ).month()) == i + 2);
+ assert(ym.year() == y);
+ assert(static_cast<unsigned>((ym -= months{1}).month()) == i + 1);
+ assert(ym.year() == y);
+ assert(static_cast<unsigned>((ym ).month()) == i + 1);
+ assert(ym.year() == y);
+ }
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class year_month;
+
+// constexpr year_month& operator+=(const years& d) noexcept;
+// constexpr year_month& operator-=(const years& d) noexcept;
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+template <typename D, typename Ds>
+constexpr bool testConstexpr(D d1)
+{
+ if (static_cast<int>((d1 ).year()) != 1) return false;
+ if (static_cast<int>((d1 += Ds{ 1}).year()) != 2) return false;
+ if (static_cast<int>((d1 += Ds{ 2}).year()) != 4) return false;
+ if (static_cast<int>((d1 += Ds{12}).year()) != 16) return false;
+ if (static_cast<int>((d1 -= Ds{ 1}).year()) != 15) return false;
+ if (static_cast<int>((d1 -= Ds{ 2}).year()) != 13) return false;
+ if (static_cast<int>((d1 -= Ds{12}).year()) != 1) return false;
+ return true;
+}
+
+int main()
+{
+ using month = std::chrono::month;
+ using year = std::chrono::year;
+ using years = std::chrono::years;
+ using year_month = std::chrono::year_month;
+
+
+ ASSERT_NOEXCEPT( std::declval<year_month&>() += std::declval<years>());
+ ASSERT_SAME_TYPE(year_month&, decltype(std::declval<year_month&>() += std::declval<years>()));
+
+ ASSERT_NOEXCEPT( std::declval<year_month&>() -= std::declval<years>());
+ ASSERT_SAME_TYPE(year_month&, decltype(std::declval<year_month&>() -= std::declval<years>()));
+
+ static_assert(testConstexpr<year_month, years>(year_month{year{1}, month{1}}), "");
+
+ for (int i = 1000; i <= 1010; ++i)
+ {
+ month m{2};
+ year_month ym(year{i}, m);
+ assert(static_cast<int>((ym += years{2}).year()) == i + 2);
+ assert(ym.month() == m);
+ assert(static_cast<int>((ym ).year()) == i + 2);
+ assert(ym.month() == m);
+ assert(static_cast<int>((ym -= years{1}).year()) == i + 1);
+ assert(ym.month() == m);
+ assert(static_cast<int>((ym ).year()) == i + 1);
+ assert(ym.month() == m);
+ }
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class year_month;
+
+// constexpr chrono::day day() const noexcept;
+// Returns: d_
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+ using year = std::chrono::year;
+ using month = std::chrono::month;
+ using year_month = std::chrono::year_month;
+
+ ASSERT_NOEXCEPT( std::declval<const year_month>().year());
+ ASSERT_SAME_TYPE(year, decltype(std::declval<const year_month>().year()));
+
+ static_assert( year_month{}.year() == year{}, "");
+
+ for (int i = 1; i <= 50; ++i)
+ {
+ year_month ym(year{i}, month{});
+ assert( static_cast<int>(ym.year()) == i);
+ }
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class year_month;
+
+// constexpr bool operator==(const year_month& x, const year_month& y) noexcept;
+// Returns: x.year() == y.year() && x.month() == y.month().
+//
+// constexpr bool operator< (const year_month& x, const year_month& y) noexcept;
+// Returns:
+// If x.year() < y.year() returns true.
+// Otherwise, if x.year() > y.year() returns false.
+// Otherwise, returns x.month() < y.month().
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+#include "test_comparisons.h"
+
+int main()
+{
+ using year = std::chrono::year;
+ using month = std::chrono::month;
+ using year_month = std::chrono::year_month;
+
+ AssertComparisons6AreNoexcept<year_month>();
+ AssertComparisons6ReturnBool<year_month>();
+
+ static_assert( testComparisons6(
+ year_month{year{1234}, std::chrono::January},
+ year_month{year{1234}, std::chrono::January},
+ true, false), "");
+
+ static_assert( testComparisons6(
+ year_month{year{1234}, std::chrono::January},
+ year_month{year{1234}, std::chrono::February},
+ false, true), "");
+
+ static_assert( testComparisons6(
+ year_month{year{1234}, std::chrono::January},
+ year_month{year{1235}, std::chrono::January},
+ false, true), "");
+
+// same year, different months
+ for (unsigned i = 1; i < 12; ++i)
+ for (unsigned j = 1; j < 12; ++j)
+ assert((testComparisons6(
+ year_month{year{1234}, month{i}},
+ year_month{year{1234}, month{j}},
+ i == j, i < j )));
+
+// same month, different years
+ for (int i = 1000; i < 20; ++i)
+ for (int j = 1000; j < 20; ++j)
+ assert((testComparisons6(
+ year_month{year{i}, std::chrono::January},
+ year_month{year{j}, std::chrono::January},
+ i == j, i < j )));
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class year_month;
+
+// constexpr year_month operator-(const year_month& ym, const years& dy) noexcept;
+// Returns: ym + -dy.
+//
+// constexpr year_month operator-(const year_month& ym, const months& dm) noexcept;
+// Returns: ym + -dm.
+//
+// constexpr months operator-(const year_month& x, const year_month& y) noexcept;
+// Returns: x.year() - y.year() + months{static_cast<int>(unsigned{x.month()}) -
+// static_cast<int>(unsigned{y.month()})}
+
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+#include <iostream>
+
+int main()
+{
+ using year = std::chrono::year;
+ using years = std::chrono::years;
+ using month = std::chrono::month;
+ using months = std::chrono::months;
+ using year_month = std::chrono::year_month;
+
+ { // year_month - years
+ ASSERT_NOEXCEPT( std::declval<year_month>() - std::declval<years>());
+ ASSERT_SAME_TYPE(year_month, decltype(std::declval<year_month>() - std::declval<years>()));
+
+// static_assert(testConstexprYears (year_month{year{1}, month{1}}), "");
+
+ year_month ym{year{1234}, std::chrono::January};
+ for (int i = 0; i <= 10; ++i)
+ {
+ year_month ym1 = ym - years{i};
+ assert(static_cast<int>(ym1.year()) == 1234 - i);
+ assert(ym1.month() == std::chrono::January);
+ }
+ }
+
+ { // year_month - months
+ ASSERT_NOEXCEPT( std::declval<year_month>() - std::declval<months>());
+ ASSERT_SAME_TYPE(year_month, decltype(std::declval<year_month>() - std::declval<months>()));
+
+// static_assert(testConstexprMonths(year_month{year{1}, month{1}}), "");
+
+ year_month ym{year{1234}, std::chrono::November};
+ for (int i = 0; i <= 10; ++i) // TODO test wrap-around
+ {
+ year_month ym1 = ym - months{i};
+ assert(static_cast<int>(ym1.year()) == 1234);
+ assert(ym1.month() == month(11 - i));
+ }
+ }
+
+ { // year_month - year_month
+ ASSERT_NOEXCEPT( std::declval<year_month>() - std::declval<year_month>());
+ ASSERT_SAME_TYPE(months, decltype(std::declval<year_month>() - std::declval<year_month>()));
+
+// static_assert(testConstexprMonths(year_month{year{1}, month{1}}), "");
+
+// Same year
+ year y{2345};
+ for (int i = 1; i <= 12; ++i)
+ for (int j = 1; j <= 12; ++j)
+ {
+ months diff = year_month{y, month(i)} - year_month{y, month(j)};
+ std::cout << "i: " << i << " j: " << j << " -> " << diff.count() << std::endl;
+ assert(diff.count() == i - j);
+ }
+
+// TODO: different year
+
+ }
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class year_month;
+
+// constexpr year_month operator+(const year_month& ym, const years& dy) noexcept;
+// Returns: (ym.year() + dy) / ym.month().
+//
+// constexpr year_month operator+(const years& dy, const year_month& ym) noexcept;
+// Returns: ym + dy.
+//
+// constexpr year_month operator+(const year_month& ym, const months& dm) noexcept;
+// Returns: A year_month value z such that z - ym == dm.
+// Complexity: O(1) with respect to the value of dm.
+//
+// constexpr year_month operator+(const months& dm, const year_month& ym) noexcept;
+// Returns: ym + dm.
+
+
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+constexpr bool testConstexprYears(std::chrono::year_month ym)
+{
+ std::chrono::years offset{23};
+ if (static_cast<int>((ym ).year()) != 1) return false;
+ if (static_cast<int>((ym + offset).year()) != 24) return false;
+ if (static_cast<int>((offset + ym).year()) != 24) return false;
+ return true;
+}
+
+
+constexpr bool testConstexprMonths(std::chrono::year_month ym)
+{
+ std::chrono::months offset{6};
+ if (static_cast<unsigned>((ym ).month()) != 1) return false;
+ if (static_cast<unsigned>((ym + offset).month()) != 7) return false;
+ if (static_cast<unsigned>((offset + ym).month()) != 7) return false;
+ return true;
+}
+
+
+int main()
+{
+ using year = std::chrono::year;
+ using years = std::chrono::years;
+ using month = std::chrono::month;
+ using months = std::chrono::months;
+ using year_month = std::chrono::year_month;
+
+ { // year_month + years
+ ASSERT_NOEXCEPT(std::declval<year_month>() + std::declval<years>());
+ ASSERT_NOEXCEPT(std::declval<years>() + std::declval<year_month>());
+
+ ASSERT_SAME_TYPE(year_month, decltype(std::declval<year_month>() + std::declval<years>()));
+ ASSERT_SAME_TYPE(year_month, decltype(std::declval<years>() + std::declval<year_month>()));
+
+ static_assert(testConstexprYears (year_month{year{1}, month{1}}), "");
+
+ year_month ym{year{1234}, std::chrono::January};
+ for (int i = 0; i <= 10; ++i)
+ {
+ year_month ym1 = ym + years{i};
+ year_month ym2 = years{i} + ym;
+ assert(static_cast<int>(ym1.year()) == i + 1234);
+ assert(static_cast<int>(ym2.year()) == i + 1234);
+ assert(ym1.month() == std::chrono::January);
+ assert(ym2.month() == std::chrono::January);
+ assert(ym1 == ym2);
+ }
+ }
+
+ { // year_month + months
+ ASSERT_NOEXCEPT(std::declval<year_month>() + std::declval<months>());
+ ASSERT_NOEXCEPT(std::declval<months>() + std::declval<year_month>());
+
+ ASSERT_SAME_TYPE(year_month, decltype(std::declval<year_month>() + std::declval<months>()));
+ ASSERT_SAME_TYPE(year_month, decltype(std::declval<months>() + std::declval<year_month>()));
+
+ static_assert(testConstexprMonths(year_month{year{1}, month{1}}), "");
+
+ year_month ym{year{1234}, std::chrono::January};
+ for (int i = 0; i <= 10; ++i) // TODO test wrap-around
+ {
+ year_month ym1 = ym + months{i};
+ year_month ym2 = months{i} + ym;
+ assert(static_cast<int>(ym1.year()) == 1234);
+ assert(static_cast<int>(ym2.year()) == 1234);
+ assert(ym1.month() == month(1 + i));
+ assert(ym2.month() == month(1 + i));
+ assert(ym1 == ym2);
+ }
+ }
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+// XFAIL: *
+
+// <chrono>
+// class year_month;
+
+// template<class charT, class traits>
+// basic_ostream<charT, traits>&
+// operator<<(basic_ostream<charT, traits>& os, const year_month& ym);
+//
+// Returns: os << ym.year() << '/' << ym.month().
+//
+//
+// template<class charT, class traits>
+// basic_ostream<charT, traits>&
+// to_stream(basic_ostream<charT, traits>& os, const charT* fmt, const year_month& ym);
+//
+// Effects: Streams ym into os using the format specified by the NTCTS fmt. fmt encoding follows the rules specified in 25.11.
+//
+// template<class charT, class traits, class Alloc = allocator<charT>>
+// basic_istream<charT, traits>&
+// from_stream(basic_istream<charT, traits>& is, const charT* fmt,
+// year_month& ym, basic_string<charT, traits, Alloc>* abbrev = nullptr,
+// minutes* offset = nullptr);
+//
+// Effects: Attempts to parse the input stream is into the year_month ym using the format
+// flags given in the NTCTS fmt as specified in 25.12. If the parse fails to decode
+// a valid year_month, is.setstate(ios_- base::failbit) shall be called and ym shall
+// not be modified. If %Z is used and successfully parsed, that value will be assigned
+// to *abbrev if abbrev is non-null. If %z (or a modified variant) is used and
+// successfully parsed, that value will be assigned to *offset if offset is non-null.
+
+
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+#include <iostream>
+
+#include "test_macros.h"
+
+int main()
+{
+ using year_month = std::chrono::year_month;
+ using year = std::chrono::year;
+ using month = std::chrono::month;
+
+ std::cout << year_month{year{2018}, month{3}};
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class year_month;
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+ using year_month = std::chrono::year_month;
+
+ static_assert(std::is_trivially_copyable_v<year_month>, "");
+ static_assert(std::is_standard_layout_v<year_month>, "");
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+// XFAIL: *
+
+// <chrono>
+// class year_month_day;
+
+// explicit constexpr year_month_day(const local_days& dp) noexcept;
+//
+//
+// Effects: Constructs an object of type year_month_day that corresponds
+// to the date represented by dp
+//
+// Remarks: Equivalent to constructing with sys_days{dp.time_since_epoch()}.
+//
+// constexpr chrono::year year() const noexcept;
+// constexpr chrono::month month() const noexcept;
+// constexpr chrono::day day() const noexcept;
+// constexpr bool ok() const noexcept;
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+ using year = std::chrono::year;
+ using month = std::chrono::month;
+ using day = std::chrono::day;
+// using local_days = std::chrono::local_days;
+ using year_month_day = std::chrono::year_month_day;
+
+// ASSERT_NOEXCEPT(year_month_day{std::declval<const local_days>()});
+ assert(false);
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class year_month_day;
+
+// year_month_day() = default;
+// constexpr year_month_day(const chrono::year& y, const chrono::month& m,
+// const chrono::day& d) noexcept;
+//
+// Effects: Constructs an object of type year_month_day by initializing
+// y_ with y, m_ with m, and d_ with d.
+//
+// constexpr chrono::year year() const noexcept;
+// constexpr chrono::month month() const noexcept;
+// constexpr chrono::day day() const noexcept;
+// constexpr bool ok() const noexcept;
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+ using year = std::chrono::year;
+ using month = std::chrono::month;
+ using day = std::chrono::day;
+ using year_month_day = std::chrono::year_month_day;
+
+ ASSERT_NOEXCEPT(year_month_day{});
+ ASSERT_NOEXCEPT(year_month_day{year{1}, month{1}, day{1}});
+
+ constexpr month January = std::chrono::January;
+
+ constexpr year_month_day ym0{};
+ static_assert( ym0.year() == year{}, "");
+ static_assert( ym0.month() == month{}, "");
+ static_assert( ym0.day() == day{}, "");
+ static_assert(!ym0.ok(), "");
+
+ constexpr year_month_day ym1{year{2019}, January, day{12}};
+ static_assert( ym1.year() == year{2019}, "");
+ static_assert( ym1.month() == January, "");
+ static_assert( ym1.day() == day{12}, "");
+ static_assert( ym1.ok(), "");
+
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+// XFAIL: *
+
+// <chrono>
+// class year_month_day;
+
+// constexpr year_month_day(const sys_days& dp) noexcept;
+//
+// Effects: Constructs an object of type year_month_day that corresponds
+// to the date represented by dp
+//
+// Remarks: For any value ymd of type year_month_day for which ymd.ok() is true,
+// ymd == year_month_day{sys_days{ymd}} is true.
+//
+// constexpr chrono::year year() const noexcept;
+// constexpr chrono::month month() const noexcept;
+// constexpr bool ok() const noexcept;
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+ using year = std::chrono::year;
+ using month = std::chrono::month;
+ using day = std::chrono::day;
+// using sys_days = std::chrono::sys_days;
+ using year_month_day = std::chrono::year_month_day;
+
+// ASSERT_NOEXCEPT(year_month_day{std::declval<const sys_days>()});
+ assert(false);
+
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+// XFAIL: *
+
+// <chrono>
+// class year_month_day;
+
+// constexpr year_month_day(const year_month_day_last& ymdl) noexcept;
+//
+// Effects: Constructs an object of type year_month_day by initializing
+// y_ with ymdl.year(), m_ with ymdl.month(), and d_ with ymdl.day().
+//
+// constexpr chrono::year year() const noexcept;
+// constexpr chrono::month month() const noexcept;
+// constexpr chrono::day day() const noexcept;
+// constexpr bool ok() const noexcept;
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+ using year = std::chrono::year;
+ using month = std::chrono::month;
+ using day = std::chrono::day;
+// using year_month_day_last = std::chrono::year_month_day_last;
+ using year_month_day = std::chrono::year_month_day;
+
+// ASSERT_NOEXCEPT(year_month_day{std::declval<const year_month_day_last>()});
+ assert(false);
+
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class year_month_day;
+
+// constexpr chrono::day day() const noexcept;
+// Returns: wd_
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+ using year = std::chrono::year;
+ using month = std::chrono::month;
+ using day = std::chrono::day;
+ using year_month_day = std::chrono::year_month_day;
+
+ ASSERT_NOEXCEPT( std::declval<const year_month_day>().day());
+ ASSERT_SAME_TYPE(day, decltype(std::declval<const year_month_day>().day()));
+
+ static_assert( year_month_day{}.day() == day{}, "");
+
+ for (unsigned i = 1; i <= 50; ++i)
+ {
+ year_month_day ymd(year{1234}, month{2}, day{i});
+ assert( static_cast<unsigned>(ymd.day()) == i);
+ }
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class year_month_day;
+
+// constexpr chrono::month month() const noexcept;
+// Returns: wd_
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+ using year = std::chrono::year;
+ using month = std::chrono::month;
+ using day = std::chrono::day;
+ using year_month_day = std::chrono::year_month_day;
+
+ ASSERT_NOEXCEPT( std::declval<const year_month_day>().month());
+ ASSERT_SAME_TYPE(month, decltype(std::declval<const year_month_day>().month()));
+
+ static_assert( year_month_day{}.month() == month{}, "");
+
+ for (unsigned i = 1; i <= 50; ++i)
+ {
+ year_month_day ymd(year{1234}, month{i}, day{12});
+ assert( static_cast<unsigned>(ymd.month()) == i);
+ }
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class year_month_day;
+
+// constexpr bool ok() const noexcept;
+// Returns: m_.ok() && y_.ok().
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+ using year = std::chrono::year;
+ using month = std::chrono::month;
+ using day = std::chrono::day;
+ using year_month_day = std::chrono::year_month_day;
+
+ constexpr month January = std::chrono::January;
+
+ ASSERT_NOEXCEPT( std::declval<const year_month_day>().ok());
+ ASSERT_SAME_TYPE(bool, decltype(std::declval<const year_month_day>().ok()));
+
+ static_assert(!year_month_day{year{-32768}, month{}, day{}}.ok(), ""); // All three bad
+
+ static_assert(!year_month_day{year{-32768}, January, day{1}}.ok(), ""); // Bad year
+ static_assert(!year_month_day{year{2019}, month{}, day{1}}.ok(), ""); // Bad month
+ static_assert(!year_month_day{year{2019}, January, day{} }.ok(), ""); // Bad day
+
+ static_assert(!year_month_day{year{-32768}, month{}, day{1}}.ok(), ""); // Bad year & month
+ static_assert(!year_month_day{year{2019}, month{}, day{} }.ok(), ""); // Bad month & day
+ static_assert(!year_month_day{year{-32768}, January, day{} }.ok(), ""); // Bad year & day
+
+ static_assert( year_month_day{year{2019}, January, day{1}}.ok(), ""); // All OK
+
+ for (unsigned i = 0; i <= 50; ++i)
+ {
+ year_month_day ym{year{2019}, January, day{i}};
+ assert( ym.ok() == day{i}.ok());
+ }
+
+ for (unsigned i = 0; i <= 50; ++i)
+ {
+ year_month_day ym{year{2019}, month{i}, day{12}};
+ assert( ym.ok() == month{i}.ok());
+ }
+
+ const int ymax = static_cast<int>(year::max());
+ for (int i = ymax - 100; i <= ymax + 100; ++i)
+ {
+ year_month_day ym{year{i}, January, day{12}};
+ assert( ym.ok() == year{i}.ok());
+ }
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class year_month_day;
+
+// constexpr year_month_day& operator+=(const months& m) noexcept;
+// constexpr year_month_day& operator-=(const months& m) noexcept;
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+template <typename D, typename Ds>
+constexpr bool testConstexpr(D d1)
+{
+ if (static_cast<unsigned>((d1 ).month()) != 1) return false;
+ if (static_cast<unsigned>((d1 += Ds{ 1}).month()) != 2) return false;
+ if (static_cast<unsigned>((d1 += Ds{ 2}).month()) != 4) return false;
+ if (static_cast<unsigned>((d1 += Ds{12}).month()) != 4) return false;
+ if (static_cast<unsigned>((d1 -= Ds{ 1}).month()) != 3) return false;
+ if (static_cast<unsigned>((d1 -= Ds{ 2}).month()) != 1) return false;
+ if (static_cast<unsigned>((d1 -= Ds{12}).month()) != 1) return false;
+ return true;
+}
+
+int main()
+{
+ using year = std::chrono::year;
+ using month = std::chrono::month;
+ using day = std::chrono::day;
+ using year_month_day = std::chrono::year_month_day;
+ using months = std::chrono::months;
+
+ ASSERT_NOEXCEPT(std::declval<year_month_day&>() += std::declval<months>());
+ ASSERT_NOEXCEPT(std::declval<year_month_day&>() -= std::declval<months>());
+
+ ASSERT_SAME_TYPE(year_month_day&, decltype(std::declval<year_month_day&>() += std::declval<months>()));
+ ASSERT_SAME_TYPE(year_month_day&, decltype(std::declval<year_month_day&>() -= std::declval<months>()));
+
+ static_assert(testConstexpr<year_month_day, months>(year_month_day{year{1234}, month{1}, day{1}}), "");
+
+ for (unsigned i = 0; i <= 10; ++i)
+ {
+ year y{1234};
+ day d{23};
+ year_month_day ym(y, month{i}, d);
+ assert(static_cast<unsigned>((ym += months{2}).month()) == i + 2);
+ assert(ym.year() == y);
+ assert(ym.day() == d);
+ assert(static_cast<unsigned>((ym ).month()) == i + 2);
+ assert(ym.year() == y);
+ assert(ym.day() == d);
+ assert(static_cast<unsigned>((ym -= months{1}).month()) == i + 1);
+ assert(ym.year() == y);
+ assert(ym.day() == d);
+ assert(static_cast<unsigned>((ym ).month()) == i + 1);
+ assert(ym.year() == y);
+ assert(ym.day() == d);
+ }
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class year_month_day;
+
+// constexpr year_month_day& operator+=(const years& d) noexcept;
+// constexpr year_month_day& operator-=(const years& d) noexcept;
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+template <typename D, typename Ds>
+constexpr bool testConstexpr(D d1)
+{
+ if (static_cast<int>((d1 ).year()) != 1) return false;
+ if (static_cast<int>((d1 += Ds{ 1}).year()) != 2) return false;
+ if (static_cast<int>((d1 += Ds{ 2}).year()) != 4) return false;
+ if (static_cast<int>((d1 += Ds{12}).year()) != 16) return false;
+ if (static_cast<int>((d1 -= Ds{ 1}).year()) != 15) return false;
+ if (static_cast<int>((d1 -= Ds{ 2}).year()) != 13) return false;
+ if (static_cast<int>((d1 -= Ds{12}).year()) != 1) return false;
+ return true;
+}
+
+int main()
+{
+ using year = std::chrono::year;
+ using month = std::chrono::month;
+ using day = std::chrono::day;
+ using year_month_day = std::chrono::year_month_day;
+ using years = std::chrono::years;
+
+ ASSERT_NOEXCEPT(std::declval<year_month_day&>() += std::declval<years>());
+ ASSERT_NOEXCEPT(std::declval<year_month_day&>() -= std::declval<years>());
+
+ ASSERT_SAME_TYPE(year_month_day&, decltype(std::declval<year_month_day&>() += std::declval<years>()));
+ ASSERT_SAME_TYPE(year_month_day&, decltype(std::declval<year_month_day&>() -= std::declval<years>()));
+
+ static_assert(testConstexpr<year_month_day, years>(year_month_day{year{1}, month{1}, day{1}}), "");
+
+ for (int i = 1000; i <= 1010; ++i)
+ {
+ month m{2};
+ day d{23};
+ year_month_day ym(year{i}, m, d);
+ assert(static_cast<int>((ym += years{2}).year()) == i + 2);
+ assert(ym.month() == m);
+ assert(ym.day() == d);
+ assert(static_cast<int>((ym ).year()) == i + 2);
+ assert(ym.month() == m);
+ assert(ym.day() == d);
+ assert(static_cast<int>((ym -= years{1}).year()) == i + 1);
+ assert(ym.month() == m);
+ assert(ym.day() == d);
+ assert(static_cast<int>((ym ).year()) == i + 1);
+ assert(ym.month() == m);
+ assert(ym.day() == d);
+ }
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class year_month_day;
+
+// constexpr chrono::day day() const noexcept;
+// Returns: d_
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+ using year = std::chrono::year;
+ using month = std::chrono::month;
+ using day = std::chrono::day;
+ using year_month_day = std::chrono::year_month_day;
+
+ ASSERT_NOEXCEPT( std::declval<const year_month_day>().year());
+ ASSERT_SAME_TYPE(year, decltype(std::declval<const year_month_day>().year()));
+
+ static_assert( year_month_day{}.year() == year{}, "");
+
+ for (int i = 1; i <= 50; ++i)
+ {
+ year_month_day ym(year{i}, month{}, day{});
+ assert( static_cast<int>(ym.year()) == i);
+ }
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class year_month_day;
+
+// constexpr bool operator==(const year_month_day& x, const year_month_day& y) noexcept;
+// Returns: x.year() == y.year() && x.month() == y.month().
+//
+// constexpr bool operator< (const year_month_day& x, const year_month_day& y) noexcept;
+// Returns:
+// If x.year() < y.year() returns true.
+// Otherwise, if x.year() > y.year() returns false.
+// Otherwise, if x.month() < y.month() returns true.
+// Otherwise, if x.month() > y.month() returns false.
+// Otherwise, returns x.day() < y.day()
+
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+#include "test_comparisons.h"
+
+int main()
+{
+ using day = std::chrono::day;
+ using year = std::chrono::year;
+ using month = std::chrono::month;
+ using year_month_day = std::chrono::year_month_day;
+
+ AssertComparisons6AreNoexcept<year_month_day>();
+ AssertComparisons6ReturnBool<year_month_day>();
+
+ constexpr month January = std::chrono::January;
+ constexpr month February = std::chrono::February;
+
+ static_assert( testComparisons6(
+ year_month_day{year{1234}, January, day{1}},
+ year_month_day{year{1234}, January, day{1}},
+ true, false), "");
+
+// different day
+ static_assert( testComparisons6(
+ year_month_day{year{1234}, January, day{1}},
+ year_month_day{year{1234}, January, day{2}},
+ false, true), "");
+
+// different month
+ static_assert( testComparisons6(
+ year_month_day{year{1234}, January, day{1}},
+ year_month_day{year{1234}, February, day{1}},
+ false, true), "");
+
+// different year
+ static_assert( testComparisons6(
+ year_month_day{year{1234}, January, day{1}},
+ year_month_day{year{1235}, January, day{1}},
+ false, true), "");
+
+
+// different month and day
+ static_assert( testComparisons6(
+ year_month_day{year{1234}, January, day{2}},
+ year_month_day{year{1234}, February, day{1}},
+ false, true), "");
+
+// different year and month
+ static_assert( testComparisons6(
+ year_month_day{year{1234}, February, day{1}},
+ year_month_day{year{1235}, January, day{1}},
+ false, true), "");
+
+// different year and day
+ static_assert( testComparisons6(
+ year_month_day{year{1234}, January, day{2}},
+ year_month_day{year{1235}, January, day{1}},
+ false, true), "");
+
+// different year, month and day
+ static_assert( testComparisons6(
+ year_month_day{year{1234}, February, day{2}},
+ year_month_day{year{1235}, January, day{1}},
+ false, true), "");
+
+
+// same year, different days
+ for (unsigned i = 1; i < 28; ++i)
+ for (unsigned j = 1; j < 28; ++j)
+ assert((testComparisons6(
+ year_month_day{year{1234}, January, day{i}},
+ year_month_day{year{1234}, January, day{j}},
+ i == j, i < j )));
+
+// same year, different months
+ for (unsigned i = 1; i < 12; ++i)
+ for (unsigned j = 1; j < 12; ++j)
+ assert((testComparisons6(
+ year_month_day{year{1234}, month{i}, day{12}},
+ year_month_day{year{1234}, month{j}, day{12}},
+ i == j, i < j )));
+
+// same month, different years
+ for (int i = 1000; i < 20; ++i)
+ for (int j = 1000; j < 20; ++j)
+ assert((testComparisons6(
+ year_month_day{year{i}, January, day{12}},
+ year_month_day{year{j}, January, day{12}},
+ i == j, i < j )));
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class year_month_day;
+
+// constexpr year_month_day operator-(const year_month_day& ymd, const years& dy) noexcept;
+// Returns: ymd + (-dy)
+
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+#include <iostream>
+
+constexpr bool test_constexpr ()
+{
+ std::chrono::year_month_day ym0{std::chrono::year{1234}, std::chrono::January, std::chrono::day{12}};
+ std::chrono::year_month_day ym1 = ym0 - std::chrono::years{10};
+ return
+ ym1.year() == std::chrono::year{1234-10}
+ && ym1.month() == std::chrono::January
+ && ym1.day() == std::chrono::day{12}
+ ;
+}
+
+int main()
+{
+ using year = std::chrono::year;
+ using month = std::chrono::month;
+ using day = std::chrono::day;
+ using year_month_day = std::chrono::year_month_day;
+ using years = std::chrono::years;
+
+ ASSERT_NOEXCEPT( std::declval<year_month_day>() - std::declval<years>());
+ ASSERT_SAME_TYPE(year_month_day, decltype(std::declval<year_month_day>() - std::declval<years>()));
+
+ constexpr month January = std::chrono::January;
+
+ static_assert(test_constexpr(), "");
+
+ year_month_day ym{year{1234}, January, day{10}};
+ for (int i = 0; i <= 10; ++i)
+ {
+ year_month_day ym1 = ym - years{i};
+ assert(static_cast<int>(ym1.year()) == 1234 - i);
+ assert(ym1.month() == January);
+ assert(ym1.day() == day{10});
+ }
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class year_month_day;
+
+// constexpr year_month_day operator+(const year_month_day& ymd, const months& dm) noexcept;
+// Returns: (ymd.year() / ymd.month() + dm) / ymd.day().
+//
+// constexpr year_month_day operator+(const months& dm, const year_month_day& ymd) noexcept;
+// Returns: ymd + dm.
+//
+//
+// constexpr year_month_day operator+(const year_month_day& ymd, const years& dy) noexcept;
+// Returns: (ymd.year() + dy) / ymd.month() / ymd.day().
+//
+// constexpr year_month_day operator+(const years& dy, const year_month_day& ymd) noexcept;
+// Returns: ym + dm.
+
+
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+constexpr bool testConstexprYears(std::chrono::year_month_day ym)
+{
+ std::chrono::years offset{23};
+ if (static_cast<int>((ym ).year()) != 1) return false;
+ if (static_cast<int>((ym + offset).year()) != 24) return false;
+ if (static_cast<int>((offset + ym).year()) != 24) return false;
+ return true;
+}
+
+
+constexpr bool testConstexprMonths(std::chrono::year_month_day ym)
+{
+ std::chrono::months offset{6};
+ if (static_cast<unsigned>((ym ).month()) != 1) return false;
+ if (static_cast<unsigned>((ym + offset).month()) != 7) return false;
+ if (static_cast<unsigned>((offset + ym).month()) != 7) return false;
+ return true;
+}
+
+
+int main()
+{
+ using day = std::chrono::day;
+ using year = std::chrono::year;
+ using years = std::chrono::years;
+ using month = std::chrono::month;
+ using months = std::chrono::months;
+ using year_month_day = std::chrono::year_month_day;
+
+ { // year_month_day + months
+ ASSERT_NOEXCEPT(std::declval<year_month_day>() + std::declval<months>());
+ ASSERT_NOEXCEPT(std::declval<months>() + std::declval<year_month_day>());
+
+ ASSERT_SAME_TYPE(year_month_day, decltype(std::declval<year_month_day>() + std::declval<months>()));
+ ASSERT_SAME_TYPE(year_month_day, decltype(std::declval<months>() + std::declval<year_month_day>()));
+
+ static_assert(testConstexprMonths(year_month_day{year{1}, month{1}, day{1}}), "");
+
+ year_month_day ym{year{1234}, std::chrono::January, day{12}};
+ for (int i = 0; i <= 10; ++i) // TODO test wrap-around
+ {
+ year_month_day ym1 = ym + months{i};
+ year_month_day ym2 = months{i} + ym;
+ assert(static_cast<int>(ym1.year()) == 1234);
+ assert(static_cast<int>(ym2.year()) == 1234);
+ assert(ym1.month() == month(1 + i));
+ assert(ym2.month() == month(1 + i));
+ assert(ym1.day() == day{12});
+ assert(ym2.day() == day{12});
+ assert(ym1 == ym2);
+ }
+ }
+
+ { // year_month_day + years
+ ASSERT_NOEXCEPT(std::declval<year_month_day>() + std::declval<years>());
+ ASSERT_NOEXCEPT(std::declval<years>() + std::declval<year_month_day>());
+
+ ASSERT_SAME_TYPE(year_month_day, decltype(std::declval<year_month_day>() + std::declval<years>()));
+ ASSERT_SAME_TYPE(year_month_day, decltype(std::declval<years>() + std::declval<year_month_day>()));
+
+ static_assert(testConstexprYears (year_month_day{year{1}, month{1}, day{1}}), "");
+
+ year_month_day ym{year{1234}, std::chrono::January, day{12}};
+ for (int i = 0; i <= 10; ++i)
+ {
+ year_month_day ym1 = ym + years{i};
+ year_month_day ym2 = years{i} + ym;
+ assert(static_cast<int>(ym1.year()) == i + 1234);
+ assert(static_cast<int>(ym2.year()) == i + 1234);
+ assert(ym1.month() == std::chrono::January);
+ assert(ym2.month() == std::chrono::January);
+ assert(ym1.day() == day{12});
+ assert(ym2.day() == day{12});
+ assert(ym1 == ym2);
+ }
+ }
+
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+// XFAIL: *
+
+// <chrono>
+// class year_month_day;
+
+// template<class charT, class traits>
+// basic_ostream<charT, traits>&
+// operator<<(basic_ostream<charT, traits>& os, const year_month_day& ym);
+//
+// Returns: os << ym.year() << '/' << ym.month().
+//
+//
+// template<class charT, class traits>
+// basic_ostream<charT, traits>&
+// to_stream(basic_ostream<charT, traits>& os, const charT* fmt, const year_month_day& ym);
+//
+// Effects: Streams ym into os using the format specified by the NTCTS fmt. fmt encoding follows the rules specified in 25.11.
+//
+// template<class charT, class traits, class Alloc = allocator<charT>>
+// basic_istream<charT, traits>&
+// from_stream(basic_istream<charT, traits>& is, const charT* fmt,
+// year_month_day& ym, basic_string<charT, traits, Alloc>* abbrev = nullptr,
+// minutes* offset = nullptr);
+//
+// Effects: Attempts to parse the input stream is into the year_month_day ym using the format
+// flags given in the NTCTS fmt as specified in 25.12. If the parse fails to decode
+// a valid year_month_day, is.setstate(ios_- base::failbit) shall be called and ym shall
+// not be modified. If %Z is used and successfully parsed, that value will be assigned
+// to *abbrev if abbrev is non-null. If %z (or a modified variant) is used and
+// successfully parsed, that value will be assigned to *offset if offset is non-null.
+
+
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+#include <iostream>
+
+#include "test_macros.h"
+
+int main()
+{
+ using year_month_day = std::chrono::year_month_day;
+ using year = std::chrono::year;
+ using month = std::chrono::month;
+ using day = std::chrono::day;
+
+ std::cout << year_month_day{year{2018}, month{3}, day{12}};
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class year_month_day;
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+ using year_month_day = std::chrono::year_month_day;
+
+ static_assert(std::is_trivially_copyable_v<year_month_day>, "");
+ static_assert(std::is_standard_layout_v<year_month_day>, "");
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class year_month_day_last;
+
+// constexpr year_month_day_last(const chrono::year& y,
+// const chrono::month_day_last& mdl) noexcept;
+//
+// Effects: Constructs an object of type year_month_day_last by initializing
+// initializing y_ with y and mdl_ with mdl.
+//
+// constexpr chrono::year year() const noexcept;
+// constexpr chrono::month month() const noexcept;
+// constexpr chrono::month_day_last month_day_last() const noexcept;
+// constexpr bool ok() const noexcept;
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+ using year = std::chrono::year;
+ using month = std::chrono::month;
+ using day = std::chrono::day;
+ using month_day_last = std::chrono::month_day_last;
+ using year_month_day_last = std::chrono::year_month_day_last;
+
+ ASSERT_NOEXCEPT(year_month_day_last{year{1}, month_day_last{month{1}}});
+
+ constexpr month January = std::chrono::January;
+
+ constexpr year_month_day_last ymdl0{year{}, month_day_last{month{}}};
+ static_assert( ymdl0.year() == year{}, "");
+ static_assert( ymdl0.month() == month{}, "");
+ static_assert( ymdl0.month_day_last() == month_day_last{month{}}, "");
+ static_assert(!ymdl0.ok(), "");
+
+ constexpr year_month_day_last ymdl1{year{2019}, month_day_last{January}};
+ static_assert( ymdl1.year() == year{2019}, "");
+ static_assert( ymdl1.month() == January, "");
+ static_assert( ymdl1.month_day_last() == month_day_last{January}, "");
+ static_assert( ymdl1.ok(), "");
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+// XFAIL: *
+
+// <chrono>
+// class year_month_day_last;
+
+// constexpr chrono::day day() const noexcept;
+// Returns: wd_
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+ using year = std::chrono::year;
+ using month = std::chrono::month;
+ using day = std::chrono::day;
+ using month_day_last = std::chrono::month_day_last;
+ using year_month_day_last = std::chrono::year_month_day_last;
+
+// TODO: wait for calendar
+// ASSERT_NOEXCEPT( std::declval<const year_month_day_last>().day());
+// ASSERT_SAME_TYPE(day, decltype(std::declval<const year_month_day_last>().day()));
+//
+// static_assert( year_month_day_last{}.day() == day{}, "");
+
+ for (unsigned i = 1; i <= 12; ++i)
+ {
+ year_month_day_last ymd(year{1234}, month_day_last{month{i}});
+ assert( static_cast<unsigned>(ymd.day()) == i);
+ }
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class year_month_day_last;
+
+// constexpr chrono::month month() const noexcept;
+// Returns: wd_
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+ using year = std::chrono::year;
+ using month = std::chrono::month;
+ using day = std::chrono::day;
+ using month_day_last = std::chrono::month_day_last;
+ using year_month_day_last = std::chrono::year_month_day_last;
+
+ ASSERT_NOEXCEPT( std::declval<const year_month_day_last>().month());
+ ASSERT_SAME_TYPE(month, decltype(std::declval<const year_month_day_last>().month()));
+
+ for (unsigned i = 1; i <= 50; ++i)
+ {
+ year_month_day_last ymd(year{1234}, month_day_last{month{i}});
+ assert( static_cast<unsigned>(ymd.month()) == i);
+ }
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class year_month_day_last;
+
+// constexpr chrono::day day() const noexcept;
+// Returns: wd_
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+ using year = std::chrono::year;
+ using month = std::chrono::month;
+ using day = std::chrono::day;
+ using month_day_last = std::chrono::month_day_last;
+ using year_month_day_last = std::chrono::year_month_day_last;
+
+ ASSERT_NOEXCEPT( std::declval<const year_month_day_last>().month_day_last());
+ ASSERT_SAME_TYPE(month_day_last, decltype(std::declval<const year_month_day_last>().month_day_last()));
+
+ for (unsigned i = 1; i <= 50; ++i)
+ {
+ year_month_day_last ymdl(year{1234}, month_day_last{month{i}});
+ assert( static_cast<unsigned>(ymdl.month_day_last().month()) == i);
+ }
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class year_month_day_last;
+
+// constexpr bool ok() const noexcept;
+// Returns: m_.ok() && y_.ok().
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+ using year = std::chrono::year;
+ using month = std::chrono::month;
+ using day = std::chrono::day;
+ using month_day_last = std::chrono::month_day_last;
+ using year_month_day_last = std::chrono::year_month_day_last;
+
+ constexpr month January = std::chrono::January;
+
+ ASSERT_NOEXCEPT( std::declval<const year_month_day_last>().ok());
+ ASSERT_SAME_TYPE(bool, decltype(std::declval<const year_month_day_last>().ok()));
+
+ static_assert(!year_month_day_last{year{-32768}, month_day_last{month{}}}.ok(), ""); // both bad
+ static_assert(!year_month_day_last{year{-32768}, month_day_last{January}}.ok(), ""); // Bad year
+ static_assert(!year_month_day_last{year{2019}, month_day_last{month{}}}.ok(), ""); // Bad month
+ static_assert( year_month_day_last{year{2019}, month_day_last{January}}.ok(), ""); // All OK
+
+ for (unsigned i = 0; i <= 50; ++i)
+ {
+ year_month_day_last ym{year{2019}, month_day_last{month{i}}};
+ assert( ym.ok() == month{i}.ok());
+ }
+
+ const int ymax = static_cast<int>(year::max());
+ for (int i = ymax - 100; i <= ymax + 100; ++i)
+ {
+ year_month_day_last ym{year{i}, month_day_last{January}};
+ assert( ym.ok() == year{i}.ok());
+ }
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+// XFAIL: *
+
+// <chrono>
+// class year_month_day_last;
+
+// constexpr operator local_days() const noexcept;
+// Returns: local_days{sys_days{*this}.time_since_epoch()}.
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+ using year = std::chrono::year;
+ using month = std::chrono::month;
+ using day = std::chrono::day;
+ using month_day_last = std::chrono::month_day_last;
+ using year_month_day_last = std::chrono::year_month_day_last;
+// using sys_days = std::chrono::local_days;
+
+// ASSERT_NOEXCEPT( static_cast<local_days>(std::declval<const year_month_day_last>().year()));
+// ASSERT_SAME_TYPE(year, decltype(static_cast<local_days>(std::declval<const year_month_day_last>().year()));
+ assert(false);
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+// XFAIL: *
+
+// <chrono>
+// class year_month_day_last;
+
+// constexpr operator sys_days() const noexcept;
+// Returns: sys_days{year()/month()/day()}.
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+ using year = std::chrono::year;
+ using month = std::chrono::month;
+ using day = std::chrono::day;
+ using month_day_last = std::chrono::month_day_last;
+ using year_month_day_last = std::chrono::year_month_day_last;
+// using sys_days = std::chrono::sys_days;
+
+// ASSERT_NOEXCEPT( static_cast<sys_days>(std::declval<const year_month_day_last>().year()));
+// ASSERT_SAME_TYPE(year, decltype(static_cast<sys_days>(std::declval<const year_month_day_last>().year()));
+ assert(false);
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class year_month_day_last;
+
+// constexpr year_month_day_last& operator+=(const months& m) noexcept;
+// constexpr year_month_day_last& operator-=(const months& m) noexcept;
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+template <typename D, typename Ds>
+constexpr bool testConstexpr(D d1)
+{
+ if (static_cast<unsigned>((d1 ).month()) != 1) return false;
+ if (static_cast<unsigned>((d1 += Ds{ 1}).month()) != 2) return false;
+ if (static_cast<unsigned>((d1 += Ds{ 2}).month()) != 4) return false;
+ if (static_cast<unsigned>((d1 += Ds{12}).month()) != 4) return false;
+ if (static_cast<unsigned>((d1 -= Ds{ 1}).month()) != 3) return false;
+ if (static_cast<unsigned>((d1 -= Ds{ 2}).month()) != 1) return false;
+ if (static_cast<unsigned>((d1 -= Ds{12}).month()) != 1) return false;
+ return true;
+}
+
+int main()
+{
+ using year = std::chrono::year;
+ using month = std::chrono::month;
+ using day = std::chrono::day;
+ using month_day_last = std::chrono::month_day_last;
+ using year_month_day_last = std::chrono::year_month_day_last;
+ using months = std::chrono::months;
+
+ ASSERT_NOEXCEPT(std::declval<year_month_day_last&>() += std::declval<months>());
+ ASSERT_NOEXCEPT(std::declval<year_month_day_last&>() -= std::declval<months>());
+
+ ASSERT_SAME_TYPE(year_month_day_last&, decltype(std::declval<year_month_day_last&>() += std::declval<months>()));
+ ASSERT_SAME_TYPE(year_month_day_last&, decltype(std::declval<year_month_day_last&>() -= std::declval<months>()));
+
+ static_assert(testConstexpr<year_month_day_last, months>(year_month_day_last{year{1234}, month_day_last{month{1}}}), "");
+
+ for (unsigned i = 0; i <= 10; ++i)
+ {
+ year y{1234};
+ month_day_last mdl{month{i}};
+ year_month_day_last ym(y, mdl);
+ assert(static_cast<unsigned>((ym += months{2}).month()) == i + 2);
+ assert(ym.year() == y);
+ assert(static_cast<unsigned>((ym ).month()) == i + 2);
+ assert(ym.year() == y);
+ assert(static_cast<unsigned>((ym -= months{1}).month()) == i + 1);
+ assert(ym.year() == y);
+ assert(static_cast<unsigned>((ym ).month()) == i + 1);
+ assert(ym.year() == y);
+ }
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class year_month_day_last;
+
+// constexpr year_month_day_last& operator+=(const years& d) noexcept;
+// constexpr year_month_day_last& operator-=(const years& d) noexcept;
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+template <typename D, typename Ds>
+constexpr bool testConstexpr(D d1)
+{
+ if (static_cast<int>((d1 ).year()) != 1) return false;
+ if (static_cast<int>((d1 += Ds{ 1}).year()) != 2) return false;
+ if (static_cast<int>((d1 += Ds{ 2}).year()) != 4) return false;
+ if (static_cast<int>((d1 += Ds{12}).year()) != 16) return false;
+ if (static_cast<int>((d1 -= Ds{ 1}).year()) != 15) return false;
+ if (static_cast<int>((d1 -= Ds{ 2}).year()) != 13) return false;
+ if (static_cast<int>((d1 -= Ds{12}).year()) != 1) return false;
+ return true;
+}
+
+int main()
+{
+ using year = std::chrono::year;
+ using month = std::chrono::month;
+ using day = std::chrono::day;
+ using month_day_last = std::chrono::month_day_last;
+ using year_month_day_last = std::chrono::year_month_day_last;
+ using years = std::chrono::years;
+
+ ASSERT_NOEXCEPT(std::declval<year_month_day_last&>() += std::declval<years>());
+ ASSERT_NOEXCEPT(std::declval<year_month_day_last&>() -= std::declval<years>());
+
+ ASSERT_SAME_TYPE(year_month_day_last&, decltype(std::declval<year_month_day_last&>() += std::declval<years>()));
+ ASSERT_SAME_TYPE(year_month_day_last&, decltype(std::declval<year_month_day_last&>() -= std::declval<years>()));
+
+ static_assert(testConstexpr<year_month_day_last, years>(year_month_day_last{year{1}, month_day_last{month{1}}}), "");
+
+ for (int i = 1000; i <= 1010; ++i)
+ {
+ month_day_last mdl{month{2}};
+ year_month_day_last ymdl(year{i}, mdl);
+ assert(static_cast<int>((ymdl += years{2}).year()) == i + 2);
+ assert(ymdl.month_day_last() == mdl);
+ assert(static_cast<int>((ymdl ).year()) == i + 2);
+ assert(ymdl.month_day_last() == mdl);
+ assert(static_cast<int>((ymdl -= years{1}).year()) == i + 1);
+ assert(ymdl.month_day_last() == mdl);
+ assert(static_cast<int>((ymdl ).year()) == i + 1);
+ assert(ymdl.month_day_last() == mdl);
+ }
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class year_month_day_last;
+
+// constexpr chrono::day day() const noexcept;
+// Returns: d_
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+ using year = std::chrono::year;
+ using month = std::chrono::month;
+ using day = std::chrono::day;
+ using month_day_last = std::chrono::month_day_last;
+ using year_month_day_last = std::chrono::year_month_day_last;
+
+ ASSERT_NOEXCEPT( std::declval<const year_month_day_last>().year());
+ ASSERT_SAME_TYPE(year, decltype(std::declval<const year_month_day_last>().year()));
+
+ for (int i = 1; i <= 50; ++i)
+ {
+ year_month_day_last ym(year{i}, month_day_last{month{}});
+ assert( static_cast<int>(ym.year()) == i);
+ }
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class year_month_day_last;
+
+// constexpr bool operator==(const year_month_day_last& x, const year_month_day_last& y) noexcept;
+// Returns: x.year() == y.year() && x.month_day_last() == y.month_day_last().
+//
+// constexpr bool operator< (const year_month_day_last& x, const year_month_day_last& y) noexcept;
+// Returns:
+// If x.year() < y.year(), returns true.
+// Otherwise, if x.year() > y.year(), returns false.
+// Otherwise, returns x.month_day_last() < y.month_day_last()
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+#include "test_comparisons.h"
+
+int main()
+{
+ using year = std::chrono::year;
+ using month = std::chrono::month;
+ using day = std::chrono::day;
+ using month_day_last = std::chrono::month_day_last;
+ using year_month_day_last = std::chrono::year_month_day_last;
+
+ AssertComparisons6AreNoexcept<year_month_day_last>();
+ AssertComparisons6ReturnBool<year_month_day_last>();
+
+ constexpr month January = std::chrono::January;
+ constexpr month February = std::chrono::February;
+
+ static_assert( testComparisons6(
+ year_month_day_last{year{1234}, month_day_last{January}},
+ year_month_day_last{year{1234}, month_day_last{January}},
+ true, false), "");
+
+// different month
+ static_assert( testComparisons6(
+ year_month_day_last{year{1234}, month_day_last{January}},
+ year_month_day_last{year{1234}, month_day_last{February}},
+ false, true), "");
+
+// different year
+ static_assert( testComparisons6(
+ year_month_day_last{year{1234}, month_day_last{January}},
+ year_month_day_last{year{1235}, month_day_last{January}},
+ false, true), "");
+
+// different month
+ static_assert( testComparisons6(
+ year_month_day_last{year{1234}, month_day_last{January}},
+ year_month_day_last{year{1234}, month_day_last{February}},
+ false, true), "");
+
+// different year and month
+ static_assert( testComparisons6(
+ year_month_day_last{year{1234}, month_day_last{February}},
+ year_month_day_last{year{1235}, month_day_last{January}},
+ false, true), "");
+
+// same year, different months
+ for (unsigned i = 1; i < 12; ++i)
+ for (unsigned j = 1; j < 12; ++j)
+ assert((testComparisons6(
+ year_month_day_last{year{1234}, month_day_last{month{i}}},
+ year_month_day_last{year{1234}, month_day_last{month{j}}},
+ i == j, i < j )));
+
+// same month, different years
+ for (int i = 1000; i < 20; ++i)
+ for (int j = 1000; j < 20; ++j)
+ assert((testComparisons6(
+ year_month_day_last{year{i}, month_day_last{January}},
+ year_month_day_last{year{j}, month_day_last{January}},
+ i == j, i < j )));
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class year_month_day_last;
+
+// constexpr year_month_day_last
+// operator-(const year_month_day_last& ymdl, const months& dm) noexcept;
+//
+// Returns: ymdl + (-dm).
+//
+// constexpr year_month_day_last
+// operator-(const year_month_day_last& ymdl, const years& dy) noexcept;
+//
+// Returns: ymdl + (-dy).
+
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+#include <iostream>
+
+constexpr bool testConstexprYears (std::chrono::year_month_day_last ymdl)
+{
+ std::chrono::year_month_day_last ym1 = ymdl - std::chrono::years{10};
+ return
+ ym1.year() == std::chrono::year{static_cast<int>(ymdl.year()) - 10}
+ && ym1.month() == ymdl.month()
+ ;
+}
+
+constexpr bool testConstexprMonths (std::chrono::year_month_day_last ymdl)
+{
+ std::chrono::year_month_day_last ym1 = ymdl - std::chrono::months{6};
+ return
+ ym1.year() == ymdl.year()
+ && ym1.month() == std::chrono::month{static_cast<unsigned>(ymdl.month()) - 6}
+ ;
+}
+
+int main()
+{
+ using year = std::chrono::year;
+ using month = std::chrono::month;
+ using day = std::chrono::day;
+ using month_day_last = std::chrono::month_day_last;
+ using year_month_day_last = std::chrono::year_month_day_last;
+ using months = std::chrono::months;
+ using years = std::chrono::years;
+
+ constexpr month December = std::chrono::December;
+
+ { // year_month_day_last - years
+ ASSERT_NOEXCEPT( std::declval<year_month_day_last>() - std::declval<years>());
+ ASSERT_SAME_TYPE(year_month_day_last, decltype(std::declval<year_month_day_last>() - std::declval<years>()));
+
+ static_assert(testConstexprYears(year_month_day_last{year{1234}, month_day_last{December}}), "");
+ year_month_day_last ym{year{1234}, month_day_last{December}};
+ for (int i = 0; i <= 10; ++i)
+ {
+ year_month_day_last ym1 = ym - years{i};
+ assert(static_cast<int>(ym1.year()) == 1234 - i);
+ assert(ym1.month() == December);
+ }
+ }
+
+ { // year_month_day_last - months
+ ASSERT_NOEXCEPT( std::declval<year_month_day_last>() - std::declval<months>());
+ ASSERT_SAME_TYPE(year_month_day_last, decltype(std::declval<year_month_day_last>() - std::declval<months>()));
+
+ static_assert(testConstexprMonths(year_month_day_last{year{1234}, month_day_last{December}}), "");
+// TODO test wrapping
+ year_month_day_last ym{year{1234}, month_day_last{December}};
+ for (unsigned i = 0; i <= 10; ++i)
+ {
+ year_month_day_last ym1 = ym - months{i};
+ assert(static_cast<int>(ym1.year()) == 1234);
+ assert(static_cast<unsigned>(ym1.month()) == 12U-i);
+ }
+ }
+
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class year_month_day_last;
+
+// constexpr year_month_day_last
+// operator+(const year_month_day_last& ymdl, const months& dm) noexcept;
+//
+// Returns: (ymdl.year() / ymdl.month() + dm) / last.
+//
+// constexpr year_month_day_last
+// operator+(const months& dm, const year_month_day_last& ymdl) noexcept;
+//
+// Returns: ymdl + dm.
+//
+//
+// constexpr year_month_day_last
+// operator+(const year_month_day_last& ymdl, const years& dy) noexcept;
+//
+// Returns: {ymdl.year()+dy, ymdl.month_day_last()}.
+//
+// constexpr year_month_day_last
+// operator+(const years& dy, const year_month_day_last& ymdl) noexcept;
+//
+// Returns: ymdl + dy
+
+
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+constexpr bool testConstexprYears(std::chrono::year_month_day_last ymdl)
+{
+ std::chrono::years offset{23};
+ if (static_cast<int>((ymdl ).year()) != 1) return false;
+ if (static_cast<int>((ymdl + offset).year()) != 24) return false;
+ if ( (ymdl + offset).month() != ymdl.month()) return false;
+ if (static_cast<int>((offset + ymdl).year()) != 24) return false;
+ if ( (offset + ymdl).month() != ymdl.month()) return false;
+ return true;
+}
+
+
+constexpr bool testConstexprMonths(std::chrono::year_month_day_last ymdl)
+{
+ std::chrono::months offset{6};
+ if (static_cast<unsigned>((ymdl ).month()) != 1) return false;
+ if ( (ymdl + offset).year() != ymdl.year()) return false;
+ if (static_cast<unsigned>((ymdl + offset).month()) != 7) return false;
+ if (static_cast<unsigned>((offset + ymdl).month()) != 7) return false;
+ if ( (offset + ymdl).year() != ymdl.year()) return false;
+ return true;
+}
+
+
+int main()
+{
+ using year = std::chrono::year;
+ using month = std::chrono::month;
+ using day = std::chrono::day;
+ using month_day_last = std::chrono::month_day_last;
+ using year_month_day_last = std::chrono::year_month_day_last;
+ using months = std::chrono::months;
+ using years = std::chrono::years;
+
+ constexpr month January = std::chrono::January;
+
+ { // year_month_day_last + months
+ ASSERT_NOEXCEPT(std::declval<year_month_day_last>() + std::declval<months>());
+ ASSERT_NOEXCEPT(std::declval<months>() + std::declval<year_month_day_last>());
+
+ ASSERT_SAME_TYPE(year_month_day_last, decltype(std::declval<year_month_day_last>() + std::declval<months>()));
+ ASSERT_SAME_TYPE(year_month_day_last, decltype(std::declval<months>() + std::declval<year_month_day_last>()));
+
+ static_assert(testConstexprMonths(year_month_day_last{year{1}, month_day_last{January}}), "");
+
+ year_month_day_last ym{year{1234}, month_day_last{January}};
+ for (int i = 0; i <= 10; ++i) // TODO test wrap-around
+ {
+ year_month_day_last ym1 = ym + months{i};
+ year_month_day_last ym2 = months{i} + ym;
+ assert(static_cast<int>(ym1.year()) == 1234);
+ assert(static_cast<int>(ym2.year()) == 1234);
+ assert(ym1.month() == month(1 + i));
+ assert(ym2.month() == month(1 + i));
+ assert(ym1 == ym2);
+ }
+ }
+
+ { // year_month_day_last + years
+ ASSERT_NOEXCEPT(std::declval<year_month_day_last>() + std::declval<years>());
+ ASSERT_NOEXCEPT(std::declval<years>() + std::declval<year_month_day_last>());
+
+ ASSERT_SAME_TYPE(year_month_day_last, decltype(std::declval<year_month_day_last>() + std::declval<years>()));
+ ASSERT_SAME_TYPE(year_month_day_last, decltype(std::declval<years>() + std::declval<year_month_day_last>()));
+
+ static_assert(testConstexprYears(year_month_day_last{year{1}, month_day_last{January}}), "");
+
+ year_month_day_last ym{year{1234}, month_day_last{January}};
+ for (int i = 0; i <= 10; ++i)
+ {
+ year_month_day_last ym1 = ym + years{i};
+ year_month_day_last ym2 = years{i} + ym;
+ assert(static_cast<int>(ym1.year()) == i + 1234);
+ assert(static_cast<int>(ym2.year()) == i + 1234);
+ assert(ym1.month() == std::chrono::January);
+ assert(ym2.month() == std::chrono::January);
+ assert(ym1 == ym2);
+ }
+ }
+
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+// XFAIL: *
+
+// <chrono>
+// class year_month_day_last;
+
+// template<class charT, class traits>
+// basic_ostream<charT, traits>&
+// operator<<(basic_ostream<charT, traits>& os, const year_month_day_last& ymdl);
+//
+// Returns: os << ymdl.year() << '/' << ymdl.month_day_last().
+
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+#include <iostream>
+
+#include "test_macros.h"
+
+int main()
+{
+ using year_month_day_last = std::chrono::year_month_day_last;
+ using year = std::chrono::year;
+ using month = std::chrono::month;
+ using month_day_last = std::chrono::month_day_last;
+
+ std::cout << year_month_day_last{year{2018}, month_day_last{month{3}}};
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+// XFAIL: *
+
+// <chrono>
+// class year_month_weekday;
+
+// explicit constexpr year_month_weekday(const local_days& dp) noexcept;
+//
+//
+// Effects: Constructs an object of type year_month_weekday that corresponds
+// to the date represented by dp
+//
+// Remarks: Equivalent to constructing with sys_days{dp.time_since_epoch()}.
+//
+// constexpr chrono::year year() const noexcept;
+// constexpr chrono::month month() const noexcept;
+// constexpr chrono::day day() const noexcept;
+// constexpr bool ok() const noexcept;
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+ using year = std::chrono::year;
+ using month = std::chrono::month;
+ using day = std::chrono::day;
+// using local_days = std::chrono::local_days;
+ using year_month_weekday = std::chrono::year_month_weekday;
+
+// ASSERT_NOEXCEPT(year_month_weekday{std::declval<const local_days>()});
+ assert(false);
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class year_month_weekday;
+
+// year_month_weekday() = default;
+// constexpr year_month_weekday(const chrono::year& y, const chrono::month& m,
+// const chrono::weekday_indexed& wdi) noexcept;
+//
+// Effects: Constructs an object of type year_month_weekday by initializing
+// y_ with y, m_ with m, and wdi_ with wdi.
+//
+// constexpr chrono::year year() const noexcept;
+// constexpr chrono::month month() const noexcept;
+// constexpr chrono::weekday weekday() const noexcept;
+// constexpr unsigned index() const noexcept;
+// constexpr chrono::weekday_indexed weekday_indexed() const noexcept;
+// constexpr bool ok() const noexcept;
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+ using year = std::chrono::year;
+ using month = std::chrono::month;
+ using day = std::chrono::day;
+ using weekday = std::chrono::weekday;
+ using weekday_indexed = std::chrono::weekday_indexed;
+ using year_month_weekday = std::chrono::year_month_weekday;
+
+ constexpr month January = std::chrono::January;
+ constexpr weekday Tuesday = std::chrono::Tuesday;
+
+ ASSERT_NOEXCEPT(year_month_weekday{});
+ ASSERT_NOEXCEPT(year_month_weekday{year{1}, month{1}, weekday_indexed{Tuesday, 1}});
+
+ constexpr year_month_weekday ym0{};
+ static_assert( ym0.year() == year{}, "");
+ static_assert( ym0.month() == month{}, "");
+ static_assert( ym0.weekday() == weekday{}, "");
+ static_assert( ym0.index() == 0, "");
+ static_assert( ym0.weekday_indexed() == weekday_indexed{}, "");
+ static_assert(!ym0.ok(), "");
+
+ constexpr year_month_weekday ym1{year{2019}, January, weekday_indexed{Tuesday, 1}};
+ static_assert( ym1.year() == year{2019}, "");
+ static_assert( ym1.month() == January, "");
+ static_assert( ym1.weekday() == Tuesday, "");
+ static_assert( ym1.index() == 1, "");
+ static_assert( ym1.weekday_indexed() == weekday_indexed{Tuesday, 1}, "");
+ static_assert( ym1.ok(), "");
+
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+// XFAIL: *
+
+// <chrono>
+// class year_month_weekday;
+
+// constexpr year_month_weekday(const sys_days& dp) noexcept;
+//
+// Effects: Constructs an object of type year_month_weekday that corresponds
+// to the date represented by dp
+//
+// Remarks: For any value ymd of type year_month_weekday for which ymd.ok() is true,
+// ymd == year_month_weekday{sys_days{ymd}} is true.
+//
+// constexpr chrono::year year() const noexcept;
+// constexpr chrono::month month() const noexcept;
+// constexpr bool ok() const noexcept;
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+ using year = std::chrono::year;
+ using month = std::chrono::month;
+ using day = std::chrono::day;
+// using sys_days = std::chrono::sys_days;
+ using year_month_weekday = std::chrono::year_month_weekday;
+
+// ASSERT_NOEXCEPT(year_month_weekday{std::declval<const sys_days>()});
+ assert(false);
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+// XFAIL: *
+
+// <chrono>
+// class year_month_weekday;
+
+// constexpr year_month_weekday(const year_month_weekday_last& ymdl) noexcept;
+//
+// Effects: Constructs an object of type year_month_weekday by initializing
+// y_ with ymdl.year(), m_ with ymdl.month(), and d_ with ymdl.day().
+//
+// constexpr chrono::year year() const noexcept;
+// constexpr chrono::month month() const noexcept;
+// constexpr chrono::day day() const noexcept;
+// constexpr bool ok() const noexcept;
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+ using year = std::chrono::year;
+ using month = std::chrono::month;
+ using day = std::chrono::day;
+ using year_month_weekday_last = std::chrono::year_month_weekday_last;
+ using year_month_weekday = std::chrono::year_month_weekday;
+
+ ASSERT_NOEXCEPT(year_month_weekday{std::declval<const year_month_weekday_last>()});
+
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class year_month_weekday;
+
+// constexpr unsigned index() const noexcept;
+// Returns: wdi_.index()
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+ using year = std::chrono::year;
+ using month = std::chrono::month;
+ using day = std::chrono::day;
+ using weekday = std::chrono::weekday;
+ using weekday_indexed = std::chrono::weekday_indexed;
+ using year_month_weekday = std::chrono::year_month_weekday;
+
+ ASSERT_NOEXCEPT( std::declval<const year_month_weekday>().index());
+ ASSERT_SAME_TYPE(unsigned, decltype(std::declval<const year_month_weekday>().index()));
+
+ static_assert( year_month_weekday{}.index() == 0, "");
+
+ for (unsigned i = 1; i <= 50; ++i)
+ {
+ year_month_weekday ymwd0(year{1234}, month{2}, weekday_indexed{weekday{2}, i});
+ assert(ymwd0.index() == i);
+ }
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class year_month_weekday;
+
+// constexpr chrono::month month() const noexcept;
+// Returns: wd_
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+ using year = std::chrono::year;
+ using month = std::chrono::month;
+ using day = std::chrono::day;
+ using weekday = std::chrono::weekday;
+ using weekday_indexed = std::chrono::weekday_indexed;
+ using year_month_weekday = std::chrono::year_month_weekday;
+
+ ASSERT_NOEXCEPT( std::declval<const year_month_weekday>().month());
+ ASSERT_SAME_TYPE(month, decltype(std::declval<const year_month_weekday>().month()));
+
+ static_assert( year_month_weekday{}.month() == month{}, "");
+
+ for (unsigned i = 1; i <= 50; ++i)
+ {
+ year_month_weekday ymd(year{1234}, month{i}, weekday_indexed{});
+ assert( static_cast<unsigned>(ymd.month()) == i);
+ }
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class year_month_weekday;
+
+// constexpr bool ok() const noexcept;
+// Returns: m_.ok() && y_.ok().
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+ using year = std::chrono::year;
+ using month = std::chrono::month;
+ using day = std::chrono::day;
+ using weekday = std::chrono::weekday;
+ using weekday_indexed = std::chrono::weekday_indexed;
+ using year_month_weekday = std::chrono::year_month_weekday;
+
+ constexpr month January = std::chrono::January;
+ constexpr weekday Tuesday = std::chrono::Tuesday;
+
+ ASSERT_NOEXCEPT( std::declval<const year_month_weekday>().ok());
+ ASSERT_SAME_TYPE(bool, decltype(std::declval<const year_month_weekday>().ok()));
+
+ static_assert(!year_month_weekday{}.ok(), "");
+
+ static_assert(!year_month_weekday{year{-32768}, month{}, weekday_indexed{}}.ok(), ""); // All three bad
+
+ static_assert(!year_month_weekday{year{-32768}, January, weekday_indexed{Tuesday, 1}}.ok(), ""); // Bad year
+ static_assert(!year_month_weekday{year{2019}, month{}, weekday_indexed{Tuesday, 1}}.ok(), ""); // Bad month
+ static_assert(!year_month_weekday{year{2019}, January, weekday_indexed{} }.ok(), ""); // Bad day
+
+ static_assert(!year_month_weekday{year{-32768}, month{}, weekday_indexed{Tuesday, 1}}.ok(), ""); // Bad year & month
+ static_assert(!year_month_weekday{year{2019}, month{}, weekday_indexed{} }.ok(), ""); // Bad month & day
+ static_assert(!year_month_weekday{year{-32768}, January, weekday_indexed{} }.ok(), ""); // Bad year & day
+
+ static_assert( year_month_weekday{year{2019}, January, weekday_indexed{Tuesday, 1}}.ok(), ""); // All OK
+
+ for (unsigned i = 0; i <= 50; ++i)
+ {
+ year_month_weekday ym{year{2019}, January, weekday_indexed{Tuesday, i}};
+ assert((ym.ok() == weekday_indexed{Tuesday, i}.ok()));
+ }
+
+ for (unsigned i = 0; i <= 50; ++i)
+ {
+ year_month_weekday ym{year{2019}, January, weekday_indexed{weekday{i}, 1}};
+ assert((ym.ok() == weekday_indexed{weekday{i}, 1}.ok()));
+ }
+
+ for (unsigned i = 0; i <= 50; ++i)
+ {
+ year_month_weekday ym{year{2019}, month{i}, weekday_indexed{Tuesday, 1}};
+ assert((ym.ok() == month{i}.ok()));
+ }
+
+ const int ymax = static_cast<int>(year::max());
+ for (int i = ymax - 100; i <= ymax + 100; ++i)
+ {
+ year_month_weekday ym{year{i}, January, weekday_indexed{Tuesday, 1}};
+ assert((ym.ok() == year{i}.ok()));
+ }
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class year_month_weekday;
+
+// constexpr year_month_weekday& operator+=(const months& m) noexcept;
+// constexpr year_month_weekday& operator-=(const months& m) noexcept;
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+template <typename D, typename Ds>
+constexpr bool testConstexpr(D d1)
+{
+ if (static_cast<unsigned>((d1 ).month()) != 1) return false;
+ if (static_cast<unsigned>((d1 += Ds{ 1}).month()) != 2) return false;
+ if (static_cast<unsigned>((d1 += Ds{ 2}).month()) != 4) return false;
+ if (static_cast<unsigned>((d1 += Ds{12}).month()) != 4) return false;
+ if (static_cast<unsigned>((d1 -= Ds{ 1}).month()) != 3) return false;
+ if (static_cast<unsigned>((d1 -= Ds{ 2}).month()) != 1) return false;
+ if (static_cast<unsigned>((d1 -= Ds{12}).month()) != 1) return false;
+ return true;
+}
+
+int main()
+{
+ using year = std::chrono::year;
+ using month = std::chrono::month;
+ using day = std::chrono::day;
+ using weekday = std::chrono::weekday;
+ using weekday_indexed = std::chrono::weekday_indexed;
+ using year_month_weekday = std::chrono::year_month_weekday;
+ using years = std::chrono::years;
+ using months = std::chrono::months;
+
+
+ ASSERT_NOEXCEPT( std::declval<year_month_weekday&>() += std::declval<months>());
+ ASSERT_SAME_TYPE(year_month_weekday&, decltype(std::declval<year_month_weekday&>() += std::declval<months>()));
+
+ ASSERT_NOEXCEPT( std::declval<year_month_weekday&>() -= std::declval<months>());
+ ASSERT_SAME_TYPE(year_month_weekday&, decltype(std::declval<year_month_weekday&>() -= std::declval<months>()));
+
+ constexpr weekday Tuesday = std::chrono::Tuesday;
+ static_assert(testConstexpr<year_month_weekday, months>(year_month_weekday{year{1234}, month{1}, weekday_indexed{Tuesday, 2}}), "");
+
+ for (unsigned i = 0; i <= 10; ++i)
+ {
+ year y{1234};
+ year_month_weekday ymwd(y, month{i}, weekday_indexed{Tuesday, 2});
+
+ assert(static_cast<unsigned>((ymwd += months{2}).month()) == i + 2);
+ assert(ymwd.year() == y);
+ assert(ymwd.weekday() == Tuesday);
+ assert(ymwd.index() == 2);
+
+ assert(static_cast<unsigned>((ymwd ).month()) == i + 2);
+ assert(ymwd.year() == y);
+ assert(ymwd.weekday() == Tuesday);
+ assert(ymwd.index() == 2);
+
+ assert(static_cast<unsigned>((ymwd -= months{1}).month()) == i + 1);
+ assert(ymwd.year() == y);
+ assert(ymwd.weekday() == Tuesday);
+ assert(ymwd.index() == 2);
+
+ assert(static_cast<unsigned>((ymwd ).month()) == i + 1);
+ assert(ymwd.year() == y);
+ assert(ymwd.weekday() == Tuesday);
+ assert(ymwd.index() == 2);
+ }
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class year_month_weekday;
+
+// constexpr year_month_weekday& operator+=(const years& d) noexcept;
+// constexpr year_month_weekday& operator-=(const years& d) noexcept;
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+template <typename D, typename Ds>
+constexpr bool testConstexpr(D d1)
+{
+ if (static_cast<int>((d1 ).year()) != 1) return false;
+ if (static_cast<int>((d1 += Ds{ 1}).year()) != 2) return false;
+ if (static_cast<int>((d1 += Ds{ 2}).year()) != 4) return false;
+ if (static_cast<int>((d1 += Ds{12}).year()) != 16) return false;
+ if (static_cast<int>((d1 -= Ds{ 1}).year()) != 15) return false;
+ if (static_cast<int>((d1 -= Ds{ 2}).year()) != 13) return false;
+ if (static_cast<int>((d1 -= Ds{12}).year()) != 1) return false;
+ return true;
+}
+
+int main()
+{
+ using year = std::chrono::year;
+ using month = std::chrono::month;
+ using day = std::chrono::day;
+ using weekday = std::chrono::weekday;
+ using weekday_indexed = std::chrono::weekday_indexed;
+ using year_month_weekday = std::chrono::year_month_weekday;
+ using years = std::chrono::years;
+ using months = std::chrono::months;
+
+ ASSERT_NOEXCEPT( std::declval<year_month_weekday&>() += std::declval<years>());
+ ASSERT_SAME_TYPE(year_month_weekday&, decltype(std::declval<year_month_weekday&>() += std::declval<years>()));
+
+ ASSERT_NOEXCEPT( std::declval<year_month_weekday&>() -= std::declval<years>());
+ ASSERT_SAME_TYPE(year_month_weekday&, decltype(std::declval<year_month_weekday&>() -= std::declval<years>()));
+
+ constexpr weekday Tuesday = std::chrono::Tuesday;
+ constexpr month January = std::chrono::January;
+
+ static_assert(testConstexpr<year_month_weekday, years>(year_month_weekday{year{1}, January, weekday_indexed{Tuesday, 2}}), "");
+
+ for (int i = 1000; i <= 1010; ++i)
+ {
+ year_month_weekday ymwd(year{i}, January, weekday_indexed{Tuesday, 2});
+
+ assert(static_cast<int>((ymwd += years{2}).year()) == i + 2);
+ assert(ymwd.month() == January);
+ assert(ymwd.weekday() == Tuesday);
+ assert(ymwd.index() == 2);
+
+ assert(static_cast<int>((ymwd ).year()) == i + 2);
+ assert(ymwd.month() == January);
+ assert(ymwd.weekday() == Tuesday);
+ assert(ymwd.index() == 2);
+
+ assert(static_cast<int>((ymwd -= years{1}).year()) == i + 1);
+ assert(ymwd.month() == January);
+ assert(ymwd.weekday() == Tuesday);
+ assert(ymwd.index() == 2);
+
+ assert(static_cast<int>((ymwd ).year()) == i + 1);
+ assert(ymwd.month() == January);
+ assert(ymwd.weekday() == Tuesday);
+ assert(ymwd.index() == 2);
+ }
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class year_month_weekday;
+
+// constexpr chrono::weekday weekday() const noexcept;
+// Returns: wdi_.weekday()
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+ using year = std::chrono::year;
+ using month = std::chrono::month;
+ using day = std::chrono::day;
+ using weekday = std::chrono::weekday;
+ using weekday_indexed = std::chrono::weekday_indexed;
+ using year_month_weekday = std::chrono::year_month_weekday;
+
+ ASSERT_NOEXCEPT( std::declval<const year_month_weekday>().weekday());
+ ASSERT_SAME_TYPE(weekday, decltype(std::declval<const year_month_weekday>().weekday()));
+
+ static_assert( year_month_weekday{}.weekday() == weekday{}, "");
+
+ for (unsigned i = 1; i <= 50; ++i)
+ {
+ year_month_weekday ymwd0(year{1234}, month{2}, weekday_indexed{weekday{i}, 1});
+ assert(static_cast<unsigned>(ymwd0.weekday()) == i);
+ }
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class year_month_weekday;
+
+// constexpr chrono::weekday_indexed weekday_indexed() const noexcept;
+// Returns: wd_
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+ using year = std::chrono::year;
+ using month = std::chrono::month;
+ using day = std::chrono::day;
+ using weekday = std::chrono::weekday;
+ using weekday_indexed = std::chrono::weekday_indexed;
+ using year_month_weekday = std::chrono::year_month_weekday;
+
+ ASSERT_NOEXCEPT( std::declval<const year_month_weekday>().weekday_indexed());
+ ASSERT_SAME_TYPE(weekday_indexed, decltype(std::declval<const year_month_weekday>().weekday_indexed()));
+
+ static_assert( year_month_weekday{}.weekday_indexed() == weekday_indexed{}, "");
+
+ for (unsigned i = 1; i <= 50; ++i)
+ {
+ year_month_weekday ymwd0(year{1234}, month{2}, weekday_indexed{weekday{i}, 1});
+ assert( static_cast<unsigned>(ymwd0.weekday_indexed().weekday()) == i);
+ assert( static_cast<unsigned>(ymwd0.weekday_indexed().index()) == 1);
+ year_month_weekday ymwd1(year{1234}, month{2}, weekday_indexed{weekday{2}, i});
+ assert( static_cast<unsigned>(ymwd1.weekday_indexed().weekday()) == 2);
+ assert( static_cast<unsigned>(ymwd1.weekday_indexed().index()) == i);
+ }
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class year_month_weekday;
+
+// constexpr chrono::year year() const noexcept;
+// Returns: d_
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+ using year = std::chrono::year;
+ using month = std::chrono::month;
+ using day = std::chrono::day;
+ using weekday = std::chrono::weekday;
+ using weekday_indexed = std::chrono::weekday_indexed;
+ using year_month_weekday = std::chrono::year_month_weekday;
+
+ ASSERT_NOEXCEPT( std::declval<const year_month_weekday>().year());
+ ASSERT_SAME_TYPE(year, decltype(std::declval<const year_month_weekday>().year()));
+
+ static_assert( year_month_weekday{}.year() == year{}, "");
+
+ for (int i = 1; i <= 50; ++i)
+ {
+ year_month_weekday ym(year{i}, month{1}, weekday_indexed{});
+ assert( static_cast<int>(ym.year()) == i);
+ }
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class year_month_weekday;
+
+// constexpr bool operator==(const year_month_weekday& x, const year_month_weekday& y) noexcept;
+// Returns: x.year() == y.year() && x.month() == y.month() && x.weekday_indexed() == y.weekday_indexed()
+//
+
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+#include "test_comparisons.h"
+
+int main()
+{
+ using year = std::chrono::year;
+ using month = std::chrono::month;
+ using day = std::chrono::day;
+ using weekday_indexed = std::chrono::weekday_indexed;
+ using weekday = std::chrono::weekday;
+ using year_month_weekday = std::chrono::year_month_weekday;
+
+ AssertComparisons2AreNoexcept<year_month_weekday>();
+ AssertComparisons2ReturnBool<year_month_weekday>();
+
+ constexpr month January = std::chrono::January;
+ constexpr month February = std::chrono::February;
+ constexpr weekday Tuesday = std::chrono::Tuesday;
+
+ static_assert( testComparisons2(
+ year_month_weekday{year{1234}, January, weekday_indexed{Tuesday, 1}},
+ year_month_weekday{year{1234}, January, weekday_indexed{Tuesday, 1}},
+ true), "");
+
+// different day
+ static_assert( testComparisons2(
+ year_month_weekday{year{1234}, January, weekday_indexed{Tuesday, 1}},
+ year_month_weekday{year{1234}, January, weekday_indexed{Tuesday, 2}},
+ false), "");
+
+// different month
+ static_assert( testComparisons2(
+ year_month_weekday{year{1234}, January, weekday_indexed{Tuesday, 1}},
+ year_month_weekday{year{1234}, February, weekday_indexed{Tuesday, 1}},
+ false), "");
+
+// different year
+ static_assert( testComparisons2(
+ year_month_weekday{year{1234}, January, weekday_indexed{Tuesday, 1}},
+ year_month_weekday{year{1235}, January, weekday_indexed{Tuesday, 1}},
+ false), "");
+
+
+// different month and day
+ static_assert( testComparisons2(
+ year_month_weekday{year{1234}, January, weekday_indexed{Tuesday, 1}},
+ year_month_weekday{year{1234}, February, weekday_indexed{Tuesday, 2}},
+ false), "");
+
+// different year and month
+ static_assert( testComparisons2(
+ year_month_weekday{year{1234}, February, weekday_indexed{Tuesday, 1}},
+ year_month_weekday{year{1235}, January, weekday_indexed{Tuesday, 1}},
+ false), "");
+
+// different year and day
+ static_assert( testComparisons2(
+ year_month_weekday{year{1234}, January, weekday_indexed{Tuesday, 2}},
+ year_month_weekday{year{1235}, January, weekday_indexed{Tuesday, 1}},
+ false), "");
+
+// different year, month and day
+ static_assert( testComparisons2(
+ year_month_weekday{year{1234}, February, weekday_indexed{Tuesday, 2}},
+ year_month_weekday{year{1235}, January, weekday_indexed{Tuesday, 1}},
+ false), "");
+
+
+// same year, different days
+ for (unsigned i = 1; i < 28; ++i)
+ for (unsigned j = 1; j < 28; ++j)
+ assert((testComparisons2(
+ year_month_weekday{year{1234}, January, weekday_indexed{Tuesday, i}},
+ year_month_weekday{year{1234}, January, weekday_indexed{Tuesday, j}},
+ i == j)));
+
+// same year, different months
+ for (unsigned i = 1; i < 12; ++i)
+ for (unsigned j = 1; j < 12; ++j)
+ assert((testComparisons2(
+ year_month_weekday{year{1234}, month{i}, weekday_indexed{Tuesday, 1}},
+ year_month_weekday{year{1234}, month{j}, weekday_indexed{Tuesday, 1}},
+ i == j)));
+
+// same month, different years
+ for (int i = 1000; i < 20; ++i)
+ for (int j = 1000; j < 20; ++j)
+ assert((testComparisons2(
+ year_month_weekday{year{i}, January, weekday_indexed{Tuesday, 1}},
+ year_month_weekday{year{j}, January, weekday_indexed{Tuesday, 1}},
+ i == j)));
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class year_month_weekday;
+
+// constexpr year_month_weekday operator-(const year_month_weekday& ymwd, const months& dm) noexcept;
+// Returns: ymwd + (-dm).
+//
+// constexpr year_month_weekday operator-(const year_month_weekday& ymwd, const years& dy) noexcept;
+// Returns: ymwd + (-dy).
+
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+#include <iostream>
+
+constexpr bool testConstexprYears ()
+{
+ std::chrono::year_month_weekday ym0{std::chrono::year{1234}, std::chrono::January, std::chrono::weekday_indexed{std::chrono::Tuesday, 1}};
+ std::chrono::year_month_weekday ym1 = ym0 - std::chrono::years{10};
+ return
+ ym1.year() == std::chrono::year{1234-10}
+ && ym1.month() == std::chrono::January
+ && ym1.weekday() == std::chrono::Tuesday
+ && ym1.index() == 1
+ ;
+}
+
+constexpr bool testConstexprMonths ()
+{
+ std::chrono::year_month_weekday ym0{std::chrono::year{1234}, std::chrono::November, std::chrono::weekday_indexed{std::chrono::Tuesday, 1}};
+ std::chrono::year_month_weekday ym1 = ym0 - std::chrono::months{6};
+ return
+ ym1.year() == std::chrono::year{1234}
+ && ym1.month() == std::chrono::May
+ && ym1.weekday() == std::chrono::Tuesday
+ && ym1.index() == 1
+ ;
+}
+
+
+int main()
+{
+ using year = std::chrono::year;
+ using month = std::chrono::month;
+ using day = std::chrono::day;
+ using weekday = std::chrono::weekday;
+ using weekday_indexed = std::chrono::weekday_indexed;
+ using year_month_weekday = std::chrono::year_month_weekday;
+ using years = std::chrono::years;
+ using months = std::chrono::months;
+
+ constexpr month November = std::chrono::November;
+ constexpr weekday Tuesday = std::chrono::Tuesday;
+
+ { // year_month_weekday - years
+ ASSERT_NOEXCEPT( std::declval<year_month_weekday>() - std::declval<years>());
+ ASSERT_SAME_TYPE(year_month_weekday, decltype(std::declval<year_month_weekday>() - std::declval<years>()));
+
+ static_assert(testConstexprYears(), "");
+
+ year_month_weekday ym{year{1234}, November, weekday_indexed{Tuesday, 1}};
+ for (int i = 0; i <= 10; ++i)
+ {
+ year_month_weekday ym1 = ym - years{i};
+ assert(static_cast<int>(ym1.year()) == 1234 - i);
+ assert(ym1.month() == November);
+ assert(ym1.weekday() == Tuesday);
+ assert(ym1.index() == 1);
+ }
+ }
+
+ { // year_month_weekday - months
+ ASSERT_NOEXCEPT( std::declval<year_month_weekday>() - std::declval<months>());
+ ASSERT_SAME_TYPE(year_month_weekday, decltype(std::declval<year_month_weekday>() - std::declval<months>()));
+
+ static_assert(testConstexprMonths(), "");
+
+ year_month_weekday ym{year{1234}, November, weekday_indexed{Tuesday, 2}};
+ for (unsigned i = 1; i <= 10; ++i)
+ {
+ year_month_weekday ym1 = ym - months{i};
+ assert(ym1.year() == year{1234});
+ assert(ym1.month() == month{11-i});
+ assert(ym1.weekday() == Tuesday);
+ assert(ym1.index() == 2);
+ }
+ }
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class year_month_weekday;
+
+// constexpr year_month_weekday operator+(const year_month_weekday& ymd, const months& dm) noexcept;
+// Returns: (ymd.year() / ymd.month() + dm) / ymd.day().
+//
+// constexpr year_month_weekday operator+(const months& dm, const year_month_weekday& ymd) noexcept;
+// Returns: ymd + dm.
+//
+//
+// constexpr year_month_weekday operator+(const year_month_weekday& ymd, const years& dy) noexcept;
+// Returns: (ymd.year() + dy) / ymd.month() / ymd.day().
+//
+// constexpr year_month_weekday operator+(const years& dy, const year_month_weekday& ymd) noexcept;
+// Returns: ym + dm.
+
+
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+constexpr bool testConstexprYears(std::chrono::year_month_weekday ym)
+{
+ std::chrono::years offset{23};
+ if (static_cast<int>((ym ).year()) != 1) return false;
+ if (static_cast<int>((ym + offset).year()) != 24) return false;
+ if (static_cast<int>((offset + ym).year()) != 24) return false;
+ return true;
+}
+
+
+constexpr bool testConstexprMonths(std::chrono::year_month_weekday ym)
+{
+ std::chrono::months offset{6};
+ if (static_cast<unsigned>((ym ).month()) != 1) return false;
+ if (static_cast<unsigned>((ym + offset).month()) != 7) return false;
+ if (static_cast<unsigned>((offset + ym).month()) != 7) return false;
+ return true;
+}
+
+
+int main()
+{
+ using year = std::chrono::year;
+ using month = std::chrono::month;
+ using day = std::chrono::day;
+ using weekday = std::chrono::weekday;
+ using weekday_indexed = std::chrono::weekday_indexed;
+ using year_month_weekday = std::chrono::year_month_weekday;
+ using years = std::chrono::years;
+ using months = std::chrono::months;
+
+ constexpr weekday Tuesday = std::chrono::Tuesday;
+ constexpr month January = std::chrono::January;
+
+ { // year_month_weekday + months (and switched)
+ ASSERT_NOEXCEPT(std::declval<year_month_weekday>() + std::declval<months>());
+ ASSERT_NOEXCEPT(std::declval<months>() + std::declval<year_month_weekday>());
+
+ ASSERT_SAME_TYPE(year_month_weekday, decltype(std::declval<year_month_weekday>() + std::declval<months>()));
+ ASSERT_SAME_TYPE(year_month_weekday, decltype(std::declval<months>() + std::declval<year_month_weekday>()));
+
+ static_assert(testConstexprMonths(year_month_weekday{year{1}, January, weekday_indexed{Tuesday, 1}}), "");
+
+ year_month_weekday ym{year{1234}, January, weekday_indexed{Tuesday, 3}};
+ for (int i = 0; i <= 10; ++i) // TODO test wrap-around
+ {
+ year_month_weekday ym1 = ym + months{i};
+ year_month_weekday ym2 = months{i} + ym;
+ assert(static_cast<int>(ym1.year()) == 1234);
+ assert(static_cast<int>(ym2.year()) == 1234);
+ assert(ym1.month() == month(1 + i));
+ assert(ym2.month() == month(1 + i));
+ assert(ym1.weekday() == Tuesday);
+ assert(ym2.weekday() == Tuesday);
+ assert(ym1.index() == 3);
+ assert(ym2.index() == 3);
+ assert(ym1 == ym2);
+ }
+ }
+
+ { // year_month_weekday + years (and switched)
+ ASSERT_NOEXCEPT(std::declval<year_month_weekday>() + std::declval<years>());
+ ASSERT_NOEXCEPT(std::declval<years>() + std::declval<year_month_weekday>());
+
+ ASSERT_SAME_TYPE(year_month_weekday, decltype(std::declval<year_month_weekday>() + std::declval<years>()));
+ ASSERT_SAME_TYPE(year_month_weekday, decltype(std::declval<years>() + std::declval<year_month_weekday>()));
+
+ static_assert(testConstexprYears (year_month_weekday{year{1}, January, weekday_indexed{Tuesday, 1}}), "");
+
+ year_month_weekday ym{year{1234}, std::chrono::January, weekday_indexed{Tuesday, 3}};
+ for (int i = 0; i <= 10; ++i)
+ {
+ year_month_weekday ym1 = ym + years{i};
+ year_month_weekday ym2 = years{i} + ym;
+ assert(static_cast<int>(ym1.year()) == i + 1234);
+ assert(static_cast<int>(ym2.year()) == i + 1234);
+ assert(ym1.month() == January);
+ assert(ym2.month() == January);
+ assert(ym1.weekday() == Tuesday);
+ assert(ym2.weekday() == Tuesday);
+ assert(ym1.index() == 3);
+ assert(ym2.index() == 3);
+ assert(ym1 == ym2);
+ }
+ }
+
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+// XFAIL: *
+
+// <chrono>
+// class year_month_weekday;
+
+// template<class charT, class traits>
+// basic_ostream<charT, traits>&
+// operator<<(basic_ostream<charT, traits>& os, const year_month_weekday& ym);
+//
+// Returns: os << ym.year() << '/' << ym.month().
+//
+//
+// template<class charT, class traits>
+// basic_ostream<charT, traits>&
+// to_stream(basic_ostream<charT, traits>& os, const charT* fmt, const year_month_weekday& ym);
+//
+// Effects: Streams ym into os using the format specified by the NTCTS fmt. fmt encoding follows the rules specified in 25.11.
+//
+// template<class charT, class traits, class Alloc = allocator<charT>>
+// basic_istream<charT, traits>&
+// from_stream(basic_istream<charT, traits>& is, const charT* fmt,
+// year_month_weekday& ym, basic_string<charT, traits, Alloc>* abbrev = nullptr,
+// minutes* offset = nullptr);
+//
+// Effects: Attempts to parse the input stream is into the year_month_weekday ym using the format
+// flags given in the NTCTS fmt as specified in 25.12. If the parse fails to decode
+// a valid year_month_weekday, is.setstate(ios_- base::failbit) shall be called and ym shall
+// not be modified. If %Z is used and successfully parsed, that value will be assigned
+// to *abbrev if abbrev is non-null. If %z (or a modified variant) is used and
+// successfully parsed, that value will be assigned to *offset if offset is non-null.
+
+
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+#include <iostream>
+#include "test_macros.h"
+
+int main()
+{
+ using year_month_weekday = std::chrono::year_month_weekday;
+ using year = std::chrono::year;
+ using month = std::chrono::month;
+ using weekday = std::chrono::weekday;
+
+ std::cout << year_month_weekday{year{2018}, month{3}, weekday{4}};
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class year_month_weekday;
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+ using year_month_weekday = std::chrono::year_month_weekday;
+
+ static_assert(std::is_trivially_copyable_v<year_month_weekday>, "");
+ static_assert(std::is_standard_layout_v<year_month_weekday>, "");
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class year_month_weekday_last;
+
+// constexpr year_month_weekday_last(const chrono::year& y, const chrono::month& m,
+// const chrono::weekday_last& wdl) noexcept;
+//
+// Effects: Constructs an object of type year_month_weekday_last by initializing
+// y_ with y, m_ with m, and wdl_ with wdl.
+//
+// constexpr chrono::year year() const noexcept;
+// constexpr chrono::month month() const noexcept;
+// constexpr chrono::weekday weekday() const noexcept;
+// constexpr chrono::weekday_last weekday_last() const noexcept;
+// constexpr bool ok() const noexcept;
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+ using year = std::chrono::year;
+ using month = std::chrono::month;
+ using weekday = std::chrono::weekday;
+ using weekday_last = std::chrono::weekday_last;
+ using year_month_weekday_last = std::chrono::year_month_weekday_last;
+
+ constexpr month January = std::chrono::January;
+ constexpr weekday Tuesday = std::chrono::Tuesday;
+
+ ASSERT_NOEXCEPT(year_month_weekday_last{year{1}, month{1}, weekday_last{Tuesday}});
+
+ constexpr year_month_weekday_last ym1{year{2019}, January, weekday_last{Tuesday}};
+ static_assert( ym1.year() == year{2019}, "");
+ static_assert( ym1.month() == January, "");
+ static_assert( ym1.weekday() == Tuesday, "");
+ static_assert( ym1.weekday_last() == weekday_last{Tuesday}, "");
+ static_assert( ym1.ok(), "");
+
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class year_month_weekday_last;
+
+// constexpr chrono::month month() const noexcept;
+// Returns: wd_
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+ using year = std::chrono::year;
+ using month = std::chrono::month;
+ using weekday = std::chrono::weekday;
+ using weekday_last = std::chrono::weekday_last;
+ using year_month_weekday_last = std::chrono::year_month_weekday_last;
+
+ ASSERT_NOEXCEPT( std::declval<const year_month_weekday_last>().month());
+ ASSERT_SAME_TYPE(month, decltype(std::declval<const year_month_weekday_last>().month()));
+
+ static_assert( year_month_weekday_last{year{}, month{}, weekday_last{weekday{}}}.month() == month{}, "");
+
+ for (unsigned i = 1; i <= 50; ++i)
+ {
+ year_month_weekday_last ymd(year{1234}, month{i}, weekday_last{weekday{}});
+ assert( static_cast<unsigned>(ymd.month()) == i);
+ }
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class year_month_weekday_last;
+
+// constexpr bool ok() const noexcept;
+// Returns: y_.ok() && m_.ok() && wdl_.ok().
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+ using year = std::chrono::year;
+ using month = std::chrono::month;
+ using weekday = std::chrono::weekday;
+ using weekday_last = std::chrono::weekday_last;
+ using year_month_weekday_last = std::chrono::year_month_weekday_last;
+
+ constexpr month January = std::chrono::January;
+ constexpr weekday Tuesday = std::chrono::Tuesday;
+
+ ASSERT_NOEXCEPT( std::declval<const year_month_weekday_last>().ok());
+ ASSERT_SAME_TYPE(bool, decltype(std::declval<const year_month_weekday_last>().ok()));
+
+ static_assert(!year_month_weekday_last{year{-32768}, month{}, weekday_last{weekday{}}}.ok(), ""); // All three bad
+
+ static_assert(!year_month_weekday_last{year{-32768}, January, weekday_last{Tuesday}}.ok(), ""); // Bad year
+ static_assert(!year_month_weekday_last{year{2019}, month{}, weekday_last{Tuesday}}.ok(), ""); // Bad month
+ static_assert(!year_month_weekday_last{year{2019}, January, weekday_last{weekday{7}}}.ok(), ""); // Bad day
+
+ static_assert(!year_month_weekday_last{year{-32768}, month{}, weekday_last{Tuesday}}.ok(), ""); // Bad year & month
+ static_assert(!year_month_weekday_last{year{2019}, month{}, weekday_last{weekday{7}}}.ok(), ""); // Bad month & day
+ static_assert(!year_month_weekday_last{year{-32768}, January, weekday_last{weekday{7}}}.ok(), ""); // Bad year & day
+
+ static_assert( year_month_weekday_last{year{2019}, January, weekday_last{Tuesday}}.ok(), ""); // All OK
+
+ for (unsigned i = 0; i <= 50; ++i)
+ {
+ year_month_weekday_last ym{year{2019}, January, weekday_last{Tuesday}};
+ assert((ym.ok() == weekday_last{Tuesday}.ok()));
+ }
+
+ for (unsigned i = 0; i <= 50; ++i)
+ {
+ year_month_weekday_last ym{year{2019}, January, weekday_last{weekday{i}}};
+ assert((ym.ok() == weekday_last{weekday{i}}.ok()));
+ }
+
+ for (unsigned i = 0; i <= 50; ++i)
+ {
+ year_month_weekday_last ym{year{2019}, month{i}, weekday_last{Tuesday}};
+ assert((ym.ok() == month{i}.ok()));
+ }
+
+ const int ymax = static_cast<int>(year::max());
+ for (int i = ymax - 100; i <= ymax + 100; ++i)
+ {
+ year_month_weekday_last ym{year{i}, January, weekday_last{Tuesday}};
+ assert((ym.ok() == year{i}.ok()));
+ }
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+// XFAIL: *
+
+// <chrono>
+// class year_month_day_last;
+
+// constexpr operator local_days() const noexcept;
+// Returns: local_days{sys_days{*this}.time_since_epoch()}.
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+ using year = std::chrono::year;
+ using month = std::chrono::month;
+ using day = std::chrono::day;
+ using month_day_last = std::chrono::month_day_last;
+ using year_month_day_last = std::chrono::year_month_day_last;
+ using sys_days = std::chrono::local_days;
+
+ ASSERT_NOEXCEPT( static_cast<local_days>(std::declval<const year_month_day_last>().year()));
+ ASSERT_SAME_TYPE(year, decltype(static_cast<local_days>(std::declval<const year_month_day_last>().year()));
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+// XFAIL: *
+
+// <chrono>
+// class year_month_day_last;
+
+// constexpr operator sys_days() const noexcept;
+// Returns: sys_days{year()/month()/day()}.
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+ using year = std::chrono::year;
+ using month = std::chrono::month;
+ using day = std::chrono::day;
+ using month_day_last = std::chrono::month_day_last;
+ using year_month_day_last = std::chrono::year_month_day_last;
+ using sys_days = std::chrono::sys_days;
+
+ ASSERT_NOEXCEPT( static_cast<sys_days>(std::declval<const year_month_day_last>().year()));
+ ASSERT_SAME_TYPE(year, decltype(static_cast<sys_days>(std::declval<const year_month_day_last>().year()));
+
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class year_month_weekday_last;
+
+// constexpr year_month_weekday_last& operator+=(const months& m) noexcept;
+// constexpr year_month_weekday_last& operator-=(const months& m) noexcept;
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+template <typename D, typename Ds>
+constexpr bool testConstexpr(D d1)
+{
+ if (static_cast<unsigned>((d1 ).month()) != 1) return false;
+ if (static_cast<unsigned>((d1 += Ds{ 1}).month()) != 2) return false;
+ if (static_cast<unsigned>((d1 += Ds{ 2}).month()) != 4) return false;
+ if (static_cast<unsigned>((d1 += Ds{12}).month()) != 4) return false;
+ if (static_cast<unsigned>((d1 -= Ds{ 1}).month()) != 3) return false;
+ if (static_cast<unsigned>((d1 -= Ds{ 2}).month()) != 1) return false;
+ if (static_cast<unsigned>((d1 -= Ds{12}).month()) != 1) return false;
+ return true;
+}
+
+int main()
+{
+ using year = std::chrono::year;
+ using month = std::chrono::month;
+ using weekday = std::chrono::weekday;
+ using weekday_last = std::chrono::weekday_last;
+ using year_month_weekday_last = std::chrono::year_month_weekday_last;
+ using months = std::chrono::months;
+
+ ASSERT_NOEXCEPT(std::declval<year_month_weekday_last&>() += std::declval<months>());
+ ASSERT_NOEXCEPT(std::declval<year_month_weekday_last&>() -= std::declval<months>());
+
+ ASSERT_SAME_TYPE(year_month_weekday_last&, decltype(std::declval<year_month_weekday_last&>() += std::declval<months>()));
+ ASSERT_SAME_TYPE(year_month_weekday_last&, decltype(std::declval<year_month_weekday_last&>() -= std::declval<months>()));
+
+ constexpr weekday Tuesday = std::chrono::Tuesday;
+ static_assert(testConstexpr<year_month_weekday_last, months>(year_month_weekday_last{year{1234}, month{1}, weekday_last{Tuesday}}), "");
+
+ for (unsigned i = 0; i <= 10; ++i)
+ {
+ year y{1234};
+ year_month_weekday_last ymwd(y, month{i}, weekday_last{Tuesday});
+
+ assert(static_cast<unsigned>((ymwd += months{2}).month()) == i + 2);
+ assert(ymwd.year() == y);
+ assert(ymwd.weekday() == Tuesday);
+
+ assert(static_cast<unsigned>((ymwd ).month()) == i + 2);
+ assert(ymwd.year() == y);
+ assert(ymwd.weekday() == Tuesday);
+
+ assert(static_cast<unsigned>((ymwd -= months{1}).month()) == i + 1);
+ assert(ymwd.year() == y);
+ assert(ymwd.weekday() == Tuesday);
+
+ assert(static_cast<unsigned>((ymwd ).month()) == i + 1);
+ assert(ymwd.year() == y);
+ assert(ymwd.weekday() == Tuesday);
+ }
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class year_month_weekday_last;
+
+// constexpr year_month_weekday_last& operator+=(const years& d) noexcept;
+// constexpr year_month_weekday_last& operator-=(const years& d) noexcept;
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+template <typename D, typename Ds>
+constexpr bool testConstexpr(D d1)
+{
+ if (static_cast<int>((d1 ).year()) != 1) return false;
+ if (static_cast<int>((d1 += Ds{ 1}).year()) != 2) return false;
+ if (static_cast<int>((d1 += Ds{ 2}).year()) != 4) return false;
+ if (static_cast<int>((d1 += Ds{12}).year()) != 16) return false;
+ if (static_cast<int>((d1 -= Ds{ 1}).year()) != 15) return false;
+ if (static_cast<int>((d1 -= Ds{ 2}).year()) != 13) return false;
+ if (static_cast<int>((d1 -= Ds{12}).year()) != 1) return false;
+ return true;
+}
+
+int main()
+{
+ using year = std::chrono::year;
+ using month = std::chrono::month;
+ using weekday = std::chrono::weekday;
+ using weekday_last = std::chrono::weekday_last;
+ using year_month_weekday_last = std::chrono::year_month_weekday_last;
+ using years = std::chrono::years;
+
+ ASSERT_NOEXCEPT(std::declval<year_month_weekday_last&>() += std::declval<years>());
+ ASSERT_NOEXCEPT(std::declval<year_month_weekday_last&>() -= std::declval<years>());
+
+ ASSERT_SAME_TYPE(year_month_weekday_last&, decltype(std::declval<year_month_weekday_last&>() += std::declval<years>()));
+ ASSERT_SAME_TYPE(year_month_weekday_last&, decltype(std::declval<year_month_weekday_last&>() -= std::declval<years>()));
+
+ constexpr weekday Tuesday = std::chrono::Tuesday;
+ constexpr month January = std::chrono::January;
+
+ static_assert(testConstexpr<year_month_weekday_last, years>(year_month_weekday_last{year{1}, January, weekday_last{Tuesday}}), "");
+
+ for (int i = 1000; i <= 1010; ++i)
+ {
+ year_month_weekday_last ymwd(year{i}, January, weekday_last{Tuesday});
+
+ assert(static_cast<int>((ymwd += years{2}).year()) == i + 2);
+ assert(ymwd.month() == January);
+ assert(ymwd.weekday() == Tuesday);
+
+ assert(static_cast<int>((ymwd ).year()) == i + 2);
+ assert(ymwd.month() == January);
+ assert(ymwd.weekday() == Tuesday);
+
+ assert(static_cast<int>((ymwd -= years{1}).year()) == i + 1);
+ assert(ymwd.month() == January);
+ assert(ymwd.weekday() == Tuesday);
+
+ assert(static_cast<int>((ymwd ).year()) == i + 1);
+ assert(ymwd.month() == January);
+ assert(ymwd.weekday() == Tuesday);
+ }
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class year_month_weekday_last;
+
+// constexpr chrono::weekday weekday() const noexcept;
+// Returns: wdi_.weekday()
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+ using year = std::chrono::year;
+ using month = std::chrono::month;
+ using weekday = std::chrono::weekday;
+ using weekday_last = std::chrono::weekday_last;
+ using year_month_weekday_last = std::chrono::year_month_weekday_last;
+
+ ASSERT_NOEXCEPT( std::declval<const year_month_weekday_last>().weekday());
+ ASSERT_SAME_TYPE(weekday, decltype(std::declval<const year_month_weekday_last>().weekday()));
+
+ static_assert( year_month_weekday_last{year{}, month{}, weekday_last{weekday{}}}.weekday() == weekday{}, "");
+
+ for (unsigned i = 1; i <= 50; ++i)
+ {
+ year_month_weekday_last ymwdl(year{1}, month{1}, weekday_last{weekday{i}});
+ assert(static_cast<unsigned>(ymwdl.weekday()) == i);
+ }
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class year_month_weekday_last;
+
+// constexpr chrono::year year() const noexcept;
+// Returns: d_
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+ using year = std::chrono::year;
+ using month = std::chrono::month;
+ using weekday = std::chrono::weekday;
+ using weekday_last = std::chrono::weekday_last;
+ using year_month_weekday_last = std::chrono::year_month_weekday_last;
+
+ ASSERT_NOEXCEPT( std::declval<const year_month_weekday_last>().year());
+ ASSERT_SAME_TYPE(year, decltype(std::declval<const year_month_weekday_last>().year()));
+
+ static_assert( year_month_weekday_last{year{}, month{}, weekday_last{weekday{}}}.year() == year{}, "");
+
+ for (int i = 1; i <= 50; ++i)
+ {
+ year_month_weekday_last ymwdl(year{i}, month{1}, weekday_last{weekday{}});
+ assert(static_cast<int>(ymwdl.year()) == i);
+ }
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class year_month_weekday_last;
+
+// constexpr bool operator==(const year_month_weekday_last& x, const year_month_weekday_last& y) noexcept;
+// Returns: x.year() == y.year() && x.month() == y.month() && x.weekday_last() == y.weekday_last()
+//
+
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+#include "test_comparisons.h"
+
+int main()
+{
+ using year = std::chrono::year;
+ using month = std::chrono::month;
+ using weekday = std::chrono::weekday;
+ using weekday_last = std::chrono::weekday_last;
+ using year_month_weekday_last = std::chrono::year_month_weekday_last;
+
+ AssertComparisons2AreNoexcept<year_month_weekday_last>();
+ AssertComparisons2ReturnBool<year_month_weekday_last>();
+
+ constexpr month January = std::chrono::January;
+ constexpr month February = std::chrono::February;
+ constexpr weekday Tuesday = std::chrono::Tuesday;
+ constexpr weekday Wednesday = std::chrono::Wednesday;
+
+ static_assert( testComparisons2(
+ year_month_weekday_last{year{1234}, January, weekday_last{Tuesday}},
+ year_month_weekday_last{year{1234}, January, weekday_last{Tuesday}},
+ true), "");
+
+// different day
+ static_assert( testComparisons2(
+ year_month_weekday_last{year{1234}, January, weekday_last{Tuesday}},
+ year_month_weekday_last{year{1234}, January, weekday_last{Wednesday}},
+ false), "");
+
+// different month
+ static_assert( testComparisons2(
+ year_month_weekday_last{year{1234}, January, weekday_last{Tuesday}},
+ year_month_weekday_last{year{1234}, February, weekday_last{Tuesday}},
+ false), "");
+
+// different year
+ static_assert( testComparisons2(
+ year_month_weekday_last{year{1234}, January, weekday_last{Tuesday}},
+ year_month_weekday_last{year{1235}, January, weekday_last{Tuesday}},
+ false), "");
+
+
+// different month and day
+ static_assert( testComparisons2(
+ year_month_weekday_last{year{1234}, January, weekday_last{Tuesday}},
+ year_month_weekday_last{year{1234}, February, weekday_last{Wednesday}},
+ false), "");
+
+// different year and month
+ static_assert( testComparisons2(
+ year_month_weekday_last{year{1234}, February, weekday_last{Tuesday}},
+ year_month_weekday_last{year{1235}, January, weekday_last{Tuesday}},
+ false), "");
+
+// different year and day
+ static_assert( testComparisons2(
+ year_month_weekday_last{year{1234}, January, weekday_last{Wednesday}},
+ year_month_weekday_last{year{1235}, January, weekday_last{Tuesday}},
+ false), "");
+
+// different year, month and day
+ static_assert( testComparisons2(
+ year_month_weekday_last{year{1234}, February, weekday_last{Wednesday}},
+ year_month_weekday_last{year{1235}, January, weekday_last{Tuesday}},
+ false), "");
+
+
+// same year, different days
+ for (unsigned i = 1; i < 28; ++i)
+ for (unsigned j = 1; j < 28; ++j)
+ assert((testComparisons2(
+ year_month_weekday_last{year{1234}, January, weekday_last{weekday{i}}},
+ year_month_weekday_last{year{1234}, January, weekday_last{weekday{j}}},
+ i == j)));
+
+// same year, different months
+ for (unsigned i = 1; i < 12; ++i)
+ for (unsigned j = 1; j < 12; ++j)
+ assert((testComparisons2(
+ year_month_weekday_last{year{1234}, month{i}, weekday_last{Tuesday}},
+ year_month_weekday_last{year{1234}, month{j}, weekday_last{Tuesday}},
+ i == j)));
+
+// same month, different years
+ for (int i = 1000; i < 20; ++i)
+ for (int j = 1000; j < 20; ++j)
+ assert((testComparisons2(
+ year_month_weekday_last{year{i}, January, weekday_last{Tuesday}},
+ year_month_weekday_last{year{j}, January, weekday_last{Tuesday}},
+ i == j)));
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class year_month_weekday_last;
+
+// constexpr year_month_weekday_last operator-(const year_month_weekday_last& ymwdl, const months& dm) noexcept;
+// Returns: ymwdl + (-dm).
+//
+// constexpr year_month_weekday_last operator-(const year_month_weekday_last& ymwdl, const years& dy) noexcept;
+// Returns: ymwdl + (-dy).
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+#include <iostream>
+
+constexpr bool testConstexprYears(std::chrono::year_month_weekday_last ym)
+{
+ std::chrono::years offset{14};
+ if (static_cast<int>((ym ).year()) != 66) return false;
+ if (static_cast<int>((ym - offset).year()) != 52) return false;
+ return true;
+}
+
+constexpr bool testConstexprMonths(std::chrono::year_month_weekday_last ym)
+{
+ std::chrono::months offset{6};
+ if (static_cast<unsigned>((ym ).month()) != 10) return false;
+ if (static_cast<unsigned>((ym - offset).month()) != 4) return false;
+ return true;
+}
+
+int main()
+{
+ using year = std::chrono::year;
+ using month = std::chrono::month;
+ using weekday = std::chrono::weekday;
+ using weekday_last = std::chrono::weekday_last;
+ using year_month_weekday_last = std::chrono::year_month_weekday_last;
+ using years = std::chrono::years;
+ using months = std::chrono::months;
+
+ constexpr month October = std::chrono::October;
+ constexpr weekday Tuesday = std::chrono::Tuesday;
+
+ { // year_month_weekday_last - years
+
+ ASSERT_NOEXCEPT( std::declval<year_month_weekday_last>() - std::declval<years>());
+ ASSERT_SAME_TYPE(year_month_weekday_last, decltype(std::declval<year_month_weekday_last>() - std::declval<years>()));
+
+ static_assert(testConstexprYears(year_month_weekday_last{year{66}, October, weekday_last{Tuesday}}), "");
+
+ year_month_weekday_last ym{year{1234}, October, weekday_last{Tuesday}};
+ for (int i = 0; i <= 10; ++i)
+ {
+ year_month_weekday_last ym1 = ym - years{i};
+ assert(ym1.year() == year{1234 - i});
+ assert(ym1.month() == October);
+ assert(ym1.weekday() == Tuesday);
+ assert(ym1.weekday_last() == weekday_last{Tuesday});
+ }
+ }
+
+ { // year_month_weekday_last - months
+
+ ASSERT_NOEXCEPT( std::declval<year_month_weekday_last>() - std::declval<months>());
+ ASSERT_SAME_TYPE(year_month_weekday_last, decltype(std::declval<year_month_weekday_last>() - std::declval<months>()));
+
+ static_assert(testConstexprMonths(year_month_weekday_last{year{66}, October, weekday_last{Tuesday}}), "");
+
+ year_month_weekday_last ym{year{1234}, October, weekday_last{Tuesday}};
+ for (unsigned i = 0; i < 10; ++i)
+ {
+ year_month_weekday_last ym1 = ym - months{i};
+ assert(ym1.year() == year{1234});
+ assert(ym1.month() == month{10 - i});
+ assert(ym1.weekday() == Tuesday);
+ assert(ym1.weekday_last() == weekday_last{Tuesday});
+ }
+ }
+
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class year_month_weekday_last;
+
+// constexpr year_month_weekday_last operator+(const year_month_weekday_last& ymwdl, const months& dm) noexcept;
+// Returns: (ymwdl.year() / ymwdl.month() + dm) / ymwdl.weekday_last().
+//
+// constexpr year_month_weekday_last operator+(const months& dm, const year_month_weekday_last& ymwdl) noexcept;
+// Returns: ymwdl + dm.
+//
+// constexpr year_month_weekday_last operator+(const year_month_weekday_last& ymwdl, const years& dy) noexcept;
+// Returns: {ymwdl.year()+dy, ymwdl.month(), ymwdl.weekday_last()}.
+//
+// constexpr year_month_weekday_last operator+(const years& dy, const year_month_weekday_last& ymwdl) noexcept;
+// Returns: ymwdl + dy.
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+constexpr bool testConstexprYears(std::chrono::year_month_weekday_last ym)
+{
+ std::chrono::years offset{23};
+ if (static_cast<int>((ym ).year()) != 1) return false;
+ if (static_cast<int>((ym + offset).year()) != 24) return false;
+ if (static_cast<int>((offset + ym).year()) != 24) return false;
+ return true;
+}
+
+constexpr bool testConstexprMonths(std::chrono::year_month_weekday_last ym)
+{
+ std::chrono::months offset{6};
+ if (static_cast<unsigned>((ym ).month()) != 1) return false;
+ if (static_cast<unsigned>((ym + offset).month()) != 7) return false;
+ if (static_cast<unsigned>((offset + ym).month()) != 7) return false;
+ return true;
+}
+
+
+int main()
+{
+ using year = std::chrono::year;
+ using month = std::chrono::month;
+ using weekday = std::chrono::weekday;
+ using weekday_last = std::chrono::weekday_last;
+ using year_month_weekday_last = std::chrono::year_month_weekday_last;
+ using years = std::chrono::years;
+ using months = std::chrono::months;
+
+ constexpr weekday Tuesday = std::chrono::Tuesday;
+ constexpr month January = std::chrono::January;
+
+ { // year_month_weekday_last + months
+ ASSERT_NOEXCEPT(std::declval<year_month_weekday_last>() + std::declval<months>());
+ ASSERT_NOEXCEPT(std::declval<months>() + std::declval<year_month_weekday_last>());
+
+ ASSERT_SAME_TYPE(year_month_weekday_last, decltype(std::declval<year_month_weekday_last>() + std::declval<months>()));
+ ASSERT_SAME_TYPE(year_month_weekday_last, decltype(std::declval<months>() + std::declval<year_month_weekday_last>()));
+
+ static_assert(testConstexprMonths(year_month_weekday_last{year{1}, January, weekday_last{Tuesday}}), "");
+
+ year_month_weekday_last ym{year{1234}, January, weekday_last{Tuesday}};
+ for (int i = 0; i <= 10; ++i) // TODO test wrap-around
+ {
+ year_month_weekday_last ym1 = ym + months{i};
+ year_month_weekday_last ym2 = months{i} + ym;
+ assert(ym1.year() == year(1234));
+ assert(ym2.year() == year(1234));
+ assert(ym1.month() == month(1 + i));
+ assert(ym2.month() == month(1 + i));
+ assert(ym1.weekday() == Tuesday);
+ assert(ym2.weekday() == Tuesday);
+ assert(ym1.weekday_last() == weekday_last{Tuesday});
+ assert(ym2.weekday_last() == weekday_last{Tuesday});
+ assert(ym1 == ym2);
+ }
+ }
+
+ { // year_month_weekday_last + years
+ ASSERT_NOEXCEPT(std::declval<year_month_weekday_last>() + std::declval<years>());
+ ASSERT_NOEXCEPT(std::declval<years>() + std::declval<year_month_weekday_last>());
+
+ ASSERT_SAME_TYPE(year_month_weekday_last, decltype(std::declval<year_month_weekday_last>() + std::declval<years>()));
+ ASSERT_SAME_TYPE(year_month_weekday_last, decltype(std::declval<years>() + std::declval<year_month_weekday_last>()));
+
+ static_assert(testConstexprYears (year_month_weekday_last{year{1}, January, weekday_last{Tuesday}}), "");
+
+ year_month_weekday_last ym{year{1234}, std::chrono::January, weekday_last{Tuesday}};
+ for (int i = 0; i <= 10; ++i)
+ {
+ year_month_weekday_last ym1 = ym + years{i};
+ year_month_weekday_last ym2 = years{i} + ym;
+ assert(ym1.year() == year(1234 + i));
+ assert(ym2.year() == year(1234 + i));
+ assert(ym1.month() == January);
+ assert(ym2.month() == January);
+ assert(ym1.weekday() == Tuesday);
+ assert(ym2.weekday() == Tuesday);
+ assert(ym1.weekday_last() == weekday_last{Tuesday});
+ assert(ym2.weekday_last() == weekday_last{Tuesday});
+ assert(ym1 == ym2);
+ }
+ }
+
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+// XFAIL: *
+
+// <chrono>
+// class year_month_weekday_last;
+
+// template<class charT, class traits>
+// basic_ostream<charT, traits>&
+// operator<<(basic_ostream<charT, traits>& os, const year_month_weekday_last& ymwdl);
+//
+// Returns: os << ymwdl.year() << '/' << ymwdl.month() << '/' << ymwdl.weekday_last().
+
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+#include <iostream>
+
+#include "test_macros.h"
+
+int main()
+{
+ using year_month_weekday_last = std::chrono::year_month_weekday_last;
+ using year = std::chrono::year;
+ using month = std::chrono::month;
+ using weekday = std::chrono::weekday;
+ using weekday_last = std::chrono::weekday_last;
+
+ std::cout << year_month_weekday_last{year{2018}, month{3}, weekday_last{weekday{4}}};
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class year_month_weekday_last_last;
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+ using year_month_weekday_last = std::chrono::year_month_weekday_last;
+
+ static_assert(std::is_trivially_copyable_v<year_month_weekday_last>, "");
+ static_assert(std::is_standard_layout_v<year_month_weekday_last>, "");
+}
#include <type_traits>
#include <cassert>
+#include "test_macros.h"
+
int main()
{
using namespace std::literals::chrono_literals;
assert ( ns == std::chrono::nanoseconds(645));
auto ns2 = 645.ns;
assert ( ns == ns2 );
+
}
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-
// UNSUPPORTED: c++98, c++03, c++11
+
#include <chrono>
#include <cassert>
assert ( ns == nanoseconds(645));
auto ns2 = 645.ns;
assert ( ns == ns2 );
+
+#if TEST_STD_VER > 17
+ assert(Sunday == weekday(0));
+ assert(Monday == weekday(1));
+ assert(Tuesday == weekday(2));
+ assert(Wednesday == weekday(3));
+ assert(Thursday == weekday(4));
+ assert(Friday == weekday(5));
+ assert(Saturday == weekday(6));
+
+ assert(January == month(1));
+ assert(February == month(2));
+ assert(March == month(3));
+ assert(April == month(4));
+ assert(May == month(5));
+ assert(June == month(6));
+ assert(July == month(7));
+ assert(August == month(8));
+ assert(September == month(9));
+ assert(October == month(10));
+ assert(November == month(11));
+ assert(December == month(12));
+#endif
}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+
+// using weeks = duration<signed integer type of at least 22 bits, ratio_multiply<ratio<7>, days::period>>;
+
+#include <chrono>
+#include <type_traits>
+#include <limits>
+
+int main()
+{
+ typedef std::chrono::weeks D;
+ typedef D::rep Rep;
+ typedef D::period Period;
+ static_assert(std::is_signed<Rep>::value, "");
+ static_assert(std::is_integral<Rep>::value, "");
+ static_assert(std::numeric_limits<Rep>::digits >= 22, "");
+ static_assert(std::is_same_v<Period, std::ratio_multiply<std::ratio<7>, std::chrono::days::period>>, "");
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+
+// 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>
+
+int main()
+{
+ typedef std::chrono::years D;
+ typedef D::rep Rep;
+ typedef D::period Period;
+ static_assert(std::is_signed<Rep>::value, "");
+ static_assert(std::is_integral<Rep>::value, "");
+ static_assert(std::numeric_limits<Rep>::digits >= 17, "");
+ static_assert(std::is_same_v<Period, std::ratio_multiply<std::ratio<146097, 400>, std::chrono::days::period>>, "");
+}