| 1 | //===----------------------------------------------------------------------===// |
| 2 | // |
| 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 |
| 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | // UNSUPPORTED: c++03, c++11, c++14, c++17 |
| 9 | |
| 10 | // <chrono> |
| 11 | // class month; |
| 12 | |
| 13 | // constexpr month& operator++() noexcept; |
| 14 | // constexpr month operator++(int) noexcept; |
| 15 | |
| 16 | #include <chrono> |
| 17 | #include <cassert> |
| 18 | #include <type_traits> |
| 19 | #include <utility> |
| 20 | |
| 21 | #include "test_macros.h" |
| 22 | |
| 23 | constexpr bool test() { |
| 24 | using month = std::chrono::month; |
| 25 | for (unsigned i = 0; i <= 15; ++i) { |
| 26 | month m1(i); |
| 27 | month m2 = m1++; |
| 28 | assert(m1.ok()); |
| 29 | assert(m1 != m2); |
| 30 | |
| 31 | unsigned exp = i + 1; |
| 32 | while (exp > 12) |
| 33 | exp -= 12; |
| 34 | assert(static_cast<unsigned>(m1) == exp); |
| 35 | } |
| 36 | for (unsigned i = 0; i <= 15; ++i) { |
| 37 | month m1(i); |
| 38 | month m2 = ++m1; |
| 39 | assert(m1.ok()); |
| 40 | assert(m2.ok()); |
| 41 | assert(m1 == m2); |
| 42 | |
| 43 | unsigned exp = i + 1; |
| 44 | while (exp > 12) |
| 45 | exp -= 12; |
| 46 | assert(static_cast<unsigned>(m1) == exp); |
| 47 | } |
| 48 | |
| 49 | return true; |
| 50 | } |
| 51 | |
| 52 | int main(int, char**) { |
| 53 | using month = std::chrono::month; |
| 54 | |
| 55 | ASSERT_NOEXCEPT(++(std::declval<month&>())); |
| 56 | ASSERT_NOEXCEPT((std::declval<month&>())++); |
| 57 | |
| 58 | ASSERT_SAME_TYPE(month, decltype(std::declval<month&>()++)); |
| 59 | ASSERT_SAME_TYPE(month&, decltype(++std::declval<month&>())); |
| 60 | |
| 61 | test(); |
| 62 | static_assert(test()); |
| 63 | |
| 64 | return 0; |
| 65 | } |
| 66 | |