1 // -*- C++ -*- 2 //===----------------------------------------------------------------------===// 3 // 4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 5 // See https://llvm.org/LICENSE.txt for license information. 6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 7 // 8 //===----------------------------------------------------------------------===// 9 10 #ifndef _LIBCPP___CHRONO_MONTH_WEEKDAY_H 11 #define _LIBCPP___CHRONO_MONTH_WEEKDAY_H 12 13 #include <__chrono/month.h> 14 #include <__chrono/weekday.h> 15 #include <__config> 16 17 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 18 # pragma GCC system_header 19 #endif 20 21 #if _LIBCPP_STD_VER > 17 22 23 _LIBCPP_BEGIN_NAMESPACE_STD 24 25 namespace chrono 26 { 27 28 class month_weekday { 29 private: 30 chrono::month __m_; 31 chrono::weekday_indexed __wdi_; 32 public: 33 _LIBCPP_HIDE_FROM_ABI constexpr month_weekday(const chrono::month& __mval, const chrono::weekday_indexed& __wdival) noexcept 34 : __m_{__mval}, __wdi_{__wdival} {} 35 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month month() const noexcept { return __m_; } 36 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::weekday_indexed weekday_indexed() const noexcept { return __wdi_; } 37 _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __m_.ok() && __wdi_.ok(); } 38 }; 39 40 _LIBCPP_HIDE_FROM_ABI inline constexpr 41 bool operator==(const month_weekday& __lhs, const month_weekday& __rhs) noexcept 42 { return __lhs.month() == __rhs.month() && __lhs.weekday_indexed() == __rhs.weekday_indexed(); } 43 44 _LIBCPP_HIDE_FROM_ABI inline constexpr 45 bool operator!=(const month_weekday& __lhs, const month_weekday& __rhs) noexcept 46 { return !(__lhs == __rhs); } 47 48 _LIBCPP_HIDE_FROM_ABI inline constexpr 49 month_weekday operator/(const month& __lhs, const weekday_indexed& __rhs) noexcept 50 { return month_weekday{__lhs, __rhs}; } 51 52 _LIBCPP_HIDE_FROM_ABI inline constexpr 53 month_weekday operator/(int __lhs, const weekday_indexed& __rhs) noexcept 54 { return month_weekday{month(__lhs), __rhs}; } 55 56 _LIBCPP_HIDE_FROM_ABI inline constexpr 57 month_weekday operator/(const weekday_indexed& __lhs, const month& __rhs) noexcept 58 { return month_weekday{__rhs, __lhs}; } 59 60 _LIBCPP_HIDE_FROM_ABI inline constexpr 61 month_weekday operator/(const weekday_indexed& __lhs, int __rhs) noexcept 62 { return month_weekday{month(__rhs), __lhs}; } 63 64 65 class month_weekday_last { 66 chrono::month __m_; 67 chrono::weekday_last __wdl_; 68 public: 69 _LIBCPP_HIDE_FROM_ABI constexpr month_weekday_last(const chrono::month& __mval, const chrono::weekday_last& __wdlval) noexcept 70 : __m_{__mval}, __wdl_{__wdlval} {} 71 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month month() const noexcept { return __m_; } 72 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::weekday_last weekday_last() const noexcept { return __wdl_; } 73 _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __m_.ok() && __wdl_.ok(); } 74 }; 75 76 _LIBCPP_HIDE_FROM_ABI inline constexpr 77 bool operator==(const month_weekday_last& __lhs, const month_weekday_last& __rhs) noexcept 78 { return __lhs.month() == __rhs.month() && __lhs.weekday_last() == __rhs.weekday_last(); } 79 80 _LIBCPP_HIDE_FROM_ABI inline constexpr 81 bool operator!=(const month_weekday_last& __lhs, const month_weekday_last& __rhs) noexcept 82 { return !(__lhs == __rhs); } 83 84 85 _LIBCPP_HIDE_FROM_ABI inline constexpr 86 month_weekday_last operator/(const month& __lhs, const weekday_last& __rhs) noexcept 87 { return month_weekday_last{__lhs, __rhs}; } 88 89 _LIBCPP_HIDE_FROM_ABI inline constexpr 90 month_weekday_last operator/(int __lhs, const weekday_last& __rhs) noexcept 91 { return month_weekday_last{month(__lhs), __rhs}; } 92 93 _LIBCPP_HIDE_FROM_ABI inline constexpr 94 month_weekday_last operator/(const weekday_last& __lhs, const month& __rhs) noexcept 95 { return month_weekday_last{__rhs, __lhs}; } 96 97 _LIBCPP_HIDE_FROM_ABI inline constexpr 98 month_weekday_last operator/(const weekday_last& __lhs, int __rhs) noexcept 99 { return month_weekday_last{month(__rhs), __lhs}; } 100 } // namespace chrono 101 102 _LIBCPP_END_NAMESPACE_STD 103 104 #endif // _LIBCPP_STD_VER > 17 105 106 #endif // _LIBCPP___CHRONO_MONTH_WEEKDAY_H 107