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 // time_point
13
14 // template <class Clock, class Duration1, class Duration2>
15 // bool
16 // operator< (const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
17
18 // template <class Clock, class Duration1, class Duration2>
19 // bool
20 // operator> (const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
21
22 // template <class Clock, class Duration1, class Duration2>
23 // bool
24 // operator<=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
25
26 // template <class Clock, class Duration1, class Duration2>
27 // bool
28 // operator>=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
29
30 #include <chrono>
31 #include <cassert>
32
main()33 int main()
34 {
35 typedef std::chrono::system_clock Clock;
36 typedef std::chrono::milliseconds Duration1;
37 typedef std::chrono::microseconds Duration2;
38 typedef std::chrono::time_point<Clock, Duration1> T1;
39 typedef std::chrono::time_point<Clock, Duration2> T2;
40
41 {
42 T1 t1(Duration1(3));
43 T1 t2(Duration1(3));
44 assert(!(t1 < t2));
45 assert(!(t1 > t2));
46 assert( (t1 <= t2));
47 assert( (t1 >= t2));
48 }
49 {
50 T1 t1(Duration1(3));
51 T1 t2(Duration1(4));
52 assert( (t1 < t2));
53 assert(!(t1 > t2));
54 assert( (t1 <= t2));
55 assert(!(t1 >= t2));
56 }
57 {
58 T1 t1(Duration1(3));
59 T2 t2(Duration2(3000));
60 assert(!(t1 < t2));
61 assert(!(t1 > t2));
62 assert( (t1 <= t2));
63 assert( (t1 >= t2));
64 }
65 {
66 T1 t1(Duration1(3));
67 T2 t2(Duration2(3001));
68 assert( (t1 < t2));
69 assert(!(t1 > t2));
70 assert( (t1 <= t2));
71 assert(!(t1 >= t2));
72 }
73
74 #if _LIBCPP_STD_VER > 11
75 {
76 constexpr T1 t1(Duration1(3));
77 constexpr T1 t2(Duration1(3));
78 static_assert(!(t1 < t2), "");
79 static_assert(!(t1 > t2), "");
80 static_assert( (t1 <= t2), "");
81 static_assert( (t1 >= t2), "");
82 }
83 {
84 constexpr T1 t1(Duration1(3));
85 constexpr T1 t2(Duration1(4));
86 static_assert( (t1 < t2), "");
87 static_assert(!(t1 > t2), "");
88 static_assert( (t1 <= t2), "");
89 static_assert(!(t1 >= t2), "");
90 }
91 {
92 constexpr T1 t1(Duration1(3));
93 constexpr T2 t2(Duration2(3000));
94 static_assert(!(t1 < t2), "");
95 static_assert(!(t1 > t2), "");
96 static_assert( (t1 <= t2), "");
97 static_assert( (t1 >= t2), "");
98 }
99 {
100 constexpr T1 t1(Duration1(3));
101 constexpr T2 t2(Duration2(3001));
102 static_assert( (t1 < t2), "");
103 static_assert(!(t1 > t2), "");
104 static_assert( (t1 <= t2), "");
105 static_assert(!(t1 >= t2), "");
106 }
107 #endif
108 }
109