| 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 | // time_point |
| 12 | |
| 13 | // time_point& operator+=(const duration& d); |
| 14 | // constexpr in c++17 |
| 15 | |
| 16 | #include <chrono> |
| 17 | #include <cassert> |
| 18 | |
| 19 | #include "test_macros.h" |
| 20 | |
| 21 | #if TEST_STD_VER > 14 |
| 22 | constexpr bool constexpr_test() |
| 23 | { |
| 24 | typedef std::chrono::system_clock Clock; |
| 25 | typedef std::chrono::milliseconds Duration; |
| 26 | std::chrono::time_point<Clock, Duration> t(Duration(5)); |
| 27 | t += Duration(4); |
| 28 | return t.time_since_epoch() == Duration(9); |
| 29 | } |
| 30 | #endif |
| 31 | |
| 32 | int main(int, char**) |
| 33 | { |
| 34 | { |
| 35 | typedef std::chrono::system_clock Clock; |
| 36 | typedef std::chrono::milliseconds Duration; |
| 37 | std::chrono::time_point<Clock, Duration> t(Duration(3)); |
| 38 | t += Duration(2); |
| 39 | assert(t.time_since_epoch() == Duration(5)); |
| 40 | } |
| 41 | |
| 42 | #if TEST_STD_VER > 14 |
| 43 | static_assert(constexpr_test(), "" ); |
| 44 | #endif |
| 45 | |
| 46 | return 0; |
| 47 | } |
| 48 | |