1 //===----------------------------------------------------------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 // <chrono>
11
12 // duration
13
14 // constexpr common_type_t<duration> operator+() const;
15
16 #include <chrono>
17 #include <cassert>
18
19 #include "test_macros.h"
20
main()21 int main()
22 {
23 {
24 const std::chrono::minutes m(3);
25 std::chrono::minutes m2 = +m;
26 assert(m.count() == m2.count());
27 }
28 #if TEST_STD_VER >= 11
29 {
30 constexpr std::chrono::minutes m(3);
31 constexpr std::chrono::minutes m2 = +m;
32 static_assert(m.count() == m2.count(), "");
33 }
34 #endif
35
36 // P0548
37 {
38 typedef std::chrono::duration<int, std::ratio<10,10> > D10;
39 typedef std::chrono::duration<int, std::ratio< 1, 1> > D1;
40 D10 zero(0);
41 D10 one(1);
42 static_assert( (std::is_same< decltype(+one), decltype(zero-one) >::value), "");
43 static_assert( (std::is_same< decltype(zero+one), D1>::value), "");
44 static_assert( (std::is_same< decltype(+one), D1>::value), "");
45 }
46 }
47