xref: /freebsd/contrib/llvm-project/libcxx/include/__chrono/month_weekday.h (revision cb14a3fe5122c879eae1fb480ed7ce82a699ddb6)
181ad6265SDimitry Andric // -*- C++ -*-
281ad6265SDimitry Andric //===----------------------------------------------------------------------===//
381ad6265SDimitry Andric //
481ad6265SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
581ad6265SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
681ad6265SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
781ad6265SDimitry Andric //
881ad6265SDimitry Andric //===----------------------------------------------------------------------===//
981ad6265SDimitry Andric 
1081ad6265SDimitry Andric #ifndef _LIBCPP___CHRONO_MONTH_WEEKDAY_H
1181ad6265SDimitry Andric #define _LIBCPP___CHRONO_MONTH_WEEKDAY_H
1281ad6265SDimitry Andric 
1381ad6265SDimitry Andric #include <__chrono/month.h>
1481ad6265SDimitry Andric #include <__chrono/weekday.h>
1581ad6265SDimitry Andric #include <__config>
1681ad6265SDimitry Andric 
1781ad6265SDimitry Andric #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1881ad6265SDimitry Andric #  pragma GCC system_header
1981ad6265SDimitry Andric #endif
2081ad6265SDimitry Andric 
2106c3fb27SDimitry Andric #if _LIBCPP_STD_VER >= 20
2281ad6265SDimitry Andric 
2381ad6265SDimitry Andric _LIBCPP_BEGIN_NAMESPACE_STD
2481ad6265SDimitry Andric 
25*cb14a3feSDimitry Andric namespace chrono {
2681ad6265SDimitry Andric 
2781ad6265SDimitry Andric class month_weekday {
2881ad6265SDimitry Andric private:
29bdd1243dSDimitry Andric   chrono::month __m_;
30bdd1243dSDimitry Andric   chrono::weekday_indexed __wdi_;
31*cb14a3feSDimitry Andric 
3281ad6265SDimitry Andric public:
33*cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI constexpr month_weekday(const chrono::month& __mval,
34*cb14a3feSDimitry Andric                                                 const chrono::weekday_indexed& __wdival) noexcept
35bdd1243dSDimitry Andric       : __m_{__mval}, __wdi_{__wdival} {}
36bdd1243dSDimitry Andric   _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month month() const noexcept { return __m_; }
37bdd1243dSDimitry Andric   _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::weekday_indexed weekday_indexed() const noexcept { return __wdi_; }
38bdd1243dSDimitry Andric   _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __m_.ok() && __wdi_.ok(); }
3981ad6265SDimitry Andric };
4081ad6265SDimitry Andric 
41*cb14a3feSDimitry Andric _LIBCPP_HIDE_FROM_ABI inline constexpr bool
42*cb14a3feSDimitry Andric operator==(const month_weekday& __lhs, const month_weekday& __rhs) noexcept {
43*cb14a3feSDimitry Andric   return __lhs.month() == __rhs.month() && __lhs.weekday_indexed() == __rhs.weekday_indexed();
44*cb14a3feSDimitry Andric }
4581ad6265SDimitry Andric 
46*cb14a3feSDimitry Andric _LIBCPP_HIDE_FROM_ABI inline constexpr month_weekday
47*cb14a3feSDimitry Andric operator/(const month& __lhs, const weekday_indexed& __rhs) noexcept {
48*cb14a3feSDimitry Andric   return month_weekday{__lhs, __rhs};
49*cb14a3feSDimitry Andric }
5081ad6265SDimitry Andric 
51*cb14a3feSDimitry Andric _LIBCPP_HIDE_FROM_ABI inline constexpr month_weekday operator/(int __lhs, const weekday_indexed& __rhs) noexcept {
52*cb14a3feSDimitry Andric   return month_weekday{month(__lhs), __rhs};
53*cb14a3feSDimitry Andric }
5481ad6265SDimitry Andric 
55*cb14a3feSDimitry Andric _LIBCPP_HIDE_FROM_ABI inline constexpr month_weekday
56*cb14a3feSDimitry Andric operator/(const weekday_indexed& __lhs, const month& __rhs) noexcept {
57*cb14a3feSDimitry Andric   return month_weekday{__rhs, __lhs};
58*cb14a3feSDimitry Andric }
5981ad6265SDimitry Andric 
60*cb14a3feSDimitry Andric _LIBCPP_HIDE_FROM_ABI inline constexpr month_weekday operator/(const weekday_indexed& __lhs, int __rhs) noexcept {
61*cb14a3feSDimitry Andric   return month_weekday{month(__rhs), __lhs};
62*cb14a3feSDimitry Andric }
6381ad6265SDimitry Andric 
6481ad6265SDimitry Andric class month_weekday_last {
65bdd1243dSDimitry Andric   chrono::month __m_;
66bdd1243dSDimitry Andric   chrono::weekday_last __wdl_;
67*cb14a3feSDimitry Andric 
6881ad6265SDimitry Andric public:
69*cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI constexpr month_weekday_last(const chrono::month& __mval,
70*cb14a3feSDimitry Andric                                                      const chrono::weekday_last& __wdlval) noexcept
71bdd1243dSDimitry Andric       : __m_{__mval}, __wdl_{__wdlval} {}
72bdd1243dSDimitry Andric   _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month month() const noexcept { return __m_; }
73bdd1243dSDimitry Andric   _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::weekday_last weekday_last() const noexcept { return __wdl_; }
74bdd1243dSDimitry Andric   _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __m_.ok() && __wdl_.ok(); }
7581ad6265SDimitry Andric };
7681ad6265SDimitry Andric 
77*cb14a3feSDimitry Andric _LIBCPP_HIDE_FROM_ABI inline constexpr bool
78*cb14a3feSDimitry Andric operator==(const month_weekday_last& __lhs, const month_weekday_last& __rhs) noexcept {
79*cb14a3feSDimitry Andric   return __lhs.month() == __rhs.month() && __lhs.weekday_last() == __rhs.weekday_last();
80*cb14a3feSDimitry Andric }
8181ad6265SDimitry Andric 
82*cb14a3feSDimitry Andric _LIBCPP_HIDE_FROM_ABI inline constexpr month_weekday_last
83*cb14a3feSDimitry Andric operator/(const month& __lhs, const weekday_last& __rhs) noexcept {
84*cb14a3feSDimitry Andric   return month_weekday_last{__lhs, __rhs};
85*cb14a3feSDimitry Andric }
8681ad6265SDimitry Andric 
87*cb14a3feSDimitry Andric _LIBCPP_HIDE_FROM_ABI inline constexpr month_weekday_last operator/(int __lhs, const weekday_last& __rhs) noexcept {
88*cb14a3feSDimitry Andric   return month_weekday_last{month(__lhs), __rhs};
89*cb14a3feSDimitry Andric }
9081ad6265SDimitry Andric 
91*cb14a3feSDimitry Andric _LIBCPP_HIDE_FROM_ABI inline constexpr month_weekday_last
92*cb14a3feSDimitry Andric operator/(const weekday_last& __lhs, const month& __rhs) noexcept {
93*cb14a3feSDimitry Andric   return month_weekday_last{__rhs, __lhs};
94*cb14a3feSDimitry Andric }
9581ad6265SDimitry Andric 
96*cb14a3feSDimitry Andric _LIBCPP_HIDE_FROM_ABI inline constexpr month_weekday_last operator/(const weekday_last& __lhs, int __rhs) noexcept {
97*cb14a3feSDimitry Andric   return month_weekday_last{month(__rhs), __lhs};
98*cb14a3feSDimitry Andric }
9981ad6265SDimitry Andric } // namespace chrono
10081ad6265SDimitry Andric 
10181ad6265SDimitry Andric _LIBCPP_END_NAMESPACE_STD
10281ad6265SDimitry Andric 
10306c3fb27SDimitry Andric #endif // _LIBCPP_STD_VER >= 20
10481ad6265SDimitry Andric 
10581ad6265SDimitry Andric #endif // _LIBCPP___CHRONO_MONTH_WEEKDAY_H
106