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