1 //===----------------------------------------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
8 // UNSUPPORTED: c++03, c++11, c++14, c++17
13 // constexpr month_day
14 // operator/(const month& m, const day& d) noexcept;
17 // constexpr month_day
18 // operator/(const day& d, const month& m) noexcept;
21 // constexpr month_day
22 // operator/(const month& m, int d) noexcept;
23 // Returns: m / day(d).
25 // constexpr month_day
26 // operator/(int m, const day& d) noexcept;
27 // Returns: month(m) / d.
29 // constexpr month_day
30 // operator/(const day& d, int m) noexcept;
31 // Returns: month(m) / d.
34 #include <type_traits>
37 #include "test_macros.h"
41 using month_day
= std::chrono::month_day
;
42 using month
= std::chrono::month
;
43 using day
= std::chrono::day
;
45 constexpr month February
= std::chrono::February
;
47 { // operator/(const month& m, const day& d) (and switched)
48 ASSERT_NOEXCEPT ( February
/day
{1});
49 ASSERT_SAME_TYPE(month_day
, decltype(February
/day
{1}));
50 ASSERT_NOEXCEPT ( day
{1}/February
);
51 ASSERT_SAME_TYPE(month_day
, decltype(day
{1}/February
));
53 for (int i
= 1; i
<= 12; ++i
)
54 for (unsigned j
= 0; j
<= 30; ++j
)
60 assert(md1
.month() == m
);
61 assert(md1
.day() == d
);
62 assert(md2
.month() == m
);
63 assert(md2
.day() == d
);
69 { // operator/(const month& m, int d) (NOT switched)
70 ASSERT_NOEXCEPT ( February
/2);
71 ASSERT_SAME_TYPE(month_day
, decltype(February
/2));
73 for (int i
= 1; i
<= 12; ++i
)
74 for (unsigned j
= 0; j
<= 30; ++j
)
79 assert(md1
.month() == m
);
80 assert(md1
.day() == d
);
85 { // operator/(const day& d, int m) (and switched)
86 ASSERT_NOEXCEPT ( day
{2}/2);
87 ASSERT_SAME_TYPE(month_day
, decltype(day
{2}/2));
88 ASSERT_NOEXCEPT ( 2/day
{2});
89 ASSERT_SAME_TYPE(month_day
, decltype(2/day
{2}));
91 for (int i
= 1; i
<= 12; ++i
)
92 for (unsigned j
= 0; j
<= 30; ++j
)
98 assert(md1
.month() == m
);
99 assert(md1
.day() == d
);
100 assert(md2
.month() == m
);
101 assert(md2
.day() == d
);