| 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 >= 20 |
| 22 |
|
| 23 |
_LIBCPP_BEGIN_NAMESPACE_STD |
| 24 |
|
| 25 |
namespace chrono { |
| 26 |
|
| 27 |
class month_weekday { |
| 28 |
private: |
| 29 |
chrono::month __m_; |
| 30 |
chrono::weekday_indexed __wdi_; |
| 31 |
|
| 32 |
public: |
| 33 |
_LIBCPP_HIDE_FROM_ABI constexpr month_weekday(const chrono::month& __mval, |
| 34 |
const chrono::weekday_indexed& __wdival) noexcept |
| 35 |
: __m_{__mval}, __wdi_{__wdival} {} |
| 36 |
_LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month month() const noexcept { return __m_; } |
| 37 |
_LIBCPP_HIDE_FROM_ABI inline constexpr chrono::weekday_indexed weekday_indexed() const noexcept { return __wdi_; } |
| 38 |
_LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __m_.ok() && __wdi_.ok(); } |
| 39 |
}; |
| 40 |
|
| 41 |
_LIBCPP_HIDE_FROM_ABI inline constexpr bool |
| 42 |
operator==(const month_weekday& __lhs, const month_weekday& __rhs) noexcept { |
| 43 |
return __lhs.month() == __rhs.month() && __lhs.weekday_indexed() == __rhs.weekday_indexed(); |
| 44 |
} |
| 45 |
|
| 46 |
_LIBCPP_HIDE_FROM_ABI inline constexpr month_weekday |
| 47 |
operator/(const month& __lhs, const weekday_indexed& __rhs) noexcept { |
| 48 |
return month_weekday{__lhs, __rhs}; |
| 49 |
} |
| 50 |
|
| 51 |
_LIBCPP_HIDE_FROM_ABI inline constexpr month_weekday operator/(int __lhs, const weekday_indexed& __rhs) noexcept { |
| 52 |
return month_weekday{month(__lhs), __rhs}; |
| 53 |
} |
| 54 |
|
| 55 |
_LIBCPP_HIDE_FROM_ABI inline constexpr month_weekday |
| 56 |
operator/(const weekday_indexed& __lhs, const month& __rhs) noexcept { |
| 57 |
return month_weekday{__rhs, __lhs}; |
| 58 |
} |
| 59 |
|
| 60 |
_LIBCPP_HIDE_FROM_ABI inline constexpr month_weekday operator/(const weekday_indexed& __lhs, int __rhs) noexcept { |
| 61 |
return month_weekday{month(__rhs), __lhs}; |
| 62 |
} |
| 63 |
|
| 64 |
class month_weekday_last { |
| 65 |
chrono::month __m_; |
| 66 |
chrono::weekday_last __wdl_; |
| 67 |
|
| 68 |
public: |
| 69 |
_LIBCPP_HIDE_FROM_ABI constexpr month_weekday_last(const chrono::month& __mval, |
| 70 |
const chrono::weekday_last& __wdlval) noexcept |
| 71 |
: __m_{__mval}, __wdl_{__wdlval} {} |
| 72 |
_LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month month() const noexcept { return __m_; } |
| 73 |
_LIBCPP_HIDE_FROM_ABI inline constexpr chrono::weekday_last weekday_last() const noexcept { return __wdl_; } |
| 74 |
_LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __m_.ok() && __wdl_.ok(); } |
| 75 |
}; |
| 76 |
|
| 77 |
_LIBCPP_HIDE_FROM_ABI inline constexpr bool |
| 78 |
operator==(const month_weekday_last& __lhs, const month_weekday_last& __rhs) noexcept { |
| 79 |
return __lhs.month() == __rhs.month() && __lhs.weekday_last() == __rhs.weekday_last(); |
| 80 |
} |
| 81 |
|
| 82 |
_LIBCPP_HIDE_FROM_ABI inline constexpr month_weekday_last |
| 83 |
operator/(const month& __lhs, const weekday_last& __rhs) noexcept { |
| 84 |
return month_weekday_last{__lhs, __rhs}; |
| 85 |
} |
| 86 |
|
| 87 |
_LIBCPP_HIDE_FROM_ABI inline constexpr month_weekday_last operator/(int __lhs, const weekday_last& __rhs) noexcept { |
| 88 |
return month_weekday_last{month(__lhs), __rhs}; |
| 89 |
} |
| 90 |
|
| 91 |
_LIBCPP_HIDE_FROM_ABI inline constexpr month_weekday_last |
| 92 |
operator/(const weekday_last& __lhs, const month& __rhs) noexcept { |
| 93 |
return month_weekday_last{__rhs, __lhs}; |
| 94 |
} |
| 95 |
|
| 96 |
_LIBCPP_HIDE_FROM_ABI inline constexpr month_weekday_last operator/(const weekday_last& __lhs, int __rhs) noexcept { |
| 97 |
return month_weekday_last{month(__rhs), __lhs}; |
| 98 |
} |
| 99 |
} // namespace chrono |
| 100 |
|
| 101 |
_LIBCPP_END_NAMESPACE_STD |
| 102 |
|
| 103 |
#endif // _LIBCPP_STD_VER >= 20 |
| 104 |
|
| 105 |
#endif // _LIBCPP___CHRONO_MONTH_WEEKDAY_H |