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 | |
9 | // <chrono> |
10 | |
11 | // duration |
12 | |
13 | // constexpr duration operator--(int); // constexpr in C++17 |
14 | |
15 | #include <chrono> |
16 | #include <cassert> |
17 | |
18 | #include "test_macros.h" |
19 | |
20 | #if TEST_STD_VER > 14 |
21 | constexpr bool test_constexpr() |
22 | { |
23 | std::chrono::hours h1(3); |
24 | std::chrono::hours h2 = h1--; |
25 | return h1.count() == 2 && h2.count() == 3; |
26 | } |
27 | #endif |
28 | |
29 | |
30 | int main(int, char**) |
31 | { |
32 | { |
33 | std::chrono::hours h1(3); |
34 | std::chrono::hours h2 = h1--; |
35 | assert(h1.count() == 2); |
36 | assert(h2.count() == 3); |
37 | } |
38 | |
39 | #if TEST_STD_VER > 14 |
40 | static_assert(test_constexpr(), "" ); |
41 | #endif |
42 | |
43 | return 0; |
44 | } |
45 | |