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& operator+=(const month& d) noexcept;
14 // constexpr month& operator-=(const month& d) noexcept;
17 #include <type_traits>
20 #include "test_macros.h"
22 constexpr bool test() {
23 using month
= std::chrono::month
;
24 using months
= std::chrono::months
;
26 for (unsigned i
= 1; i
<= 10; ++i
) {
31 assert(static_cast<unsigned>(m
+= months
{10}) == static_cast<unsigned>(exp
));
32 assert(static_cast<unsigned>(m
) == static_cast<unsigned>(exp
));
36 for (unsigned i
= 1; i
<= 10; ++i
) {
41 assert(static_cast<unsigned>(m
-= months
{9}) == static_cast<unsigned>(exp
));
42 assert(static_cast<unsigned>(m
) == static_cast<unsigned>(exp
));
48 int main(int, char**) {
49 using month
= std::chrono::month
;
50 using months
= std::chrono::months
;
52 ASSERT_NOEXCEPT(std::declval
<month
&>() += std::declval
<months
&>());
53 ASSERT_NOEXCEPT(std::declval
<month
&>() -= std::declval
<months
&>());
54 ASSERT_SAME_TYPE(month
&, decltype(std::declval
<month
&>() += std::declval
<months
&>()));
55 ASSERT_SAME_TYPE(month
&, decltype(std::declval
<month
&>() -= std::declval
<months
&>()));
58 static_assert(test());