| 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 common_type_t<duration> operator+() const; |
| 14 | |
| 15 | #include <chrono> |
| 16 | #include <cassert> |
| 17 | #include <ratio> |
| 18 | #include <type_traits> |
| 19 | |
| 20 | #include "test_macros.h" |
| 21 | |
| 22 | int main(int, char**) |
| 23 | { |
| 24 | { |
| 25 | const std::chrono::minutes m(3); |
| 26 | std::chrono::minutes m2 = +m; |
| 27 | assert(m.count() == m2.count()); |
| 28 | } |
| 29 | #if TEST_STD_VER >= 11 |
| 30 | { |
| 31 | constexpr std::chrono::minutes m(3); |
| 32 | constexpr std::chrono::minutes m2 = +m; |
| 33 | static_assert(m.count() == m2.count(), "" ); |
| 34 | } |
| 35 | #endif |
| 36 | |
| 37 | // P0548 |
| 38 | { |
| 39 | typedef std::chrono::duration<int, std::ratio<10,10> > D10; |
| 40 | typedef std::chrono::duration<int, std::ratio< 1, 1> > D1; |
| 41 | D10 zero(0); |
| 42 | D10 one(1); |
| 43 | static_assert( (std::is_same< decltype(+one), decltype(zero-one) >::value), "" ); |
| 44 | static_assert( (std::is_same< decltype(zero+one), D1>::value), "" ); |
| 45 | static_assert( (std::is_same< decltype(+one), D1>::value), "" ); |
| 46 | } |
| 47 | |
| 48 | return 0; |
| 49 | } |
| 50 | |