//===----------------------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // UNSUPPORTED: c++03, c++11, c++14, c++17 // // class month; // constexpr month& operator+=(const month& d) noexcept; // constexpr month& operator-=(const month& d) noexcept; #include #include #include #include #include "test_macros.h" constexpr bool test() { using month = std::chrono::month; using months = std::chrono::months; for (unsigned i = 1; i <= 10; ++i) { month m(i); int exp = i + 10; while (exp > 12) exp -= 12; assert(static_cast(m += months{10}) == static_cast(exp)); assert(static_cast(m) == static_cast(exp)); assert(m.ok()); } for (unsigned i = 1; i <= 10; ++i) { month m(i); int exp = i - 9; while (exp < 1) exp += 12; assert(static_cast(m -= months{9}) == static_cast(exp)); assert(static_cast(m) == static_cast(exp)); assert(m.ok()); } return true; } int main(int, char**) { using month = std::chrono::month; using months = std::chrono::months; ASSERT_NOEXCEPT(std::declval() += std::declval()); ASSERT_NOEXCEPT(std::declval() -= std::declval()); ASSERT_SAME_TYPE(month&, decltype(std::declval() += std::declval())); ASSERT_SAME_TYPE(month&, decltype(std::declval() -= std::declval())); test(); static_assert(test()); return 0; }