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 weekday;
12
13// constexpr weekday& operator--() noexcept;
14// constexpr weekday operator--(int) noexcept;
15
16#include <chrono>
17#include <cassert>
18#include <type_traits>
19#include <utility>
20
21#include "test_macros.h"
22#include "../../euclidian.h"
23
24using weekday = std::chrono::weekday;
25
26constexpr bool test() {
27 for (unsigned i = 0; i <= 6; ++i) {
28 weekday wd(i);
29 assert(((--wd).c_encoding() == euclidian_subtraction<unsigned, 0, 6>(i, 1)));
30 assert(((wd--).c_encoding() == euclidian_subtraction<unsigned, 0, 6>(i, 1)));
31 assert(((wd).c_encoding() == euclidian_subtraction<unsigned, 0, 6>(i, 2)));
32 }
33
34 return true;
35}
36
37int main(int, char**) {
38 ASSERT_NOEXCEPT(--(std::declval<weekday&>()));
39 ASSERT_NOEXCEPT((std::declval<weekday&>())--);
40
41 ASSERT_SAME_TYPE(weekday, decltype(std::declval<weekday&>()--));
42 ASSERT_SAME_TYPE(weekday&, decltype(--std::declval<weekday&>()));
43
44 test();
45 static_assert(test());
46
47 return 0;
48}
49

source code of libcxx/test/std/time/time.cal/time.cal.weekday/time.cal.weekday.members/decrement.pass.cpp