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// <tuple>
10
11// template <class... Types> class tuple;
12
13// template<class... TTypes, class... UTypes>
14// bool
15// operator<(const tuple<TTypes...>& t, const tuple<UTypes...>& u);
16//
17// template<class... TTypes, class... UTypes>
18// bool
19// operator>(const tuple<TTypes...>& t, const tuple<UTypes...>& u);
20//
21// template<class... TTypes, class... UTypes>
22// bool
23// operator<=(const tuple<TTypes...>& t, const tuple<UTypes...>& u);
24//
25// template<class... TTypes, class... UTypes>
26// bool
27// operator>=(const tuple<TTypes...>& t, const tuple<UTypes...>& u);
28
29// UNSUPPORTED: c++03
30
31#include <tuple>
32#include <string>
33#include <cassert>
34
35#include "test_macros.h"
36
37int main(int, char**)
38{
39 {
40 typedef std::tuple<> T1;
41 typedef std::tuple<> T2;
42 const T1 t1;
43 const T2 t2;
44 assert(!(t1 < t2));
45 assert( (t1 <= t2));
46 assert(!(t1 > t2));
47 assert( (t1 >= t2));
48 }
49 {
50 typedef std::tuple<long> T1;
51 typedef std::tuple<double> T2;
52 const T1 t1(1);
53 const T2 t2(1);
54 assert(!(t1 < t2));
55 assert( (t1 <= t2));
56 assert(!(t1 > t2));
57 assert( (t1 >= t2));
58 }
59 {
60 typedef std::tuple<long> T1;
61 typedef std::tuple<double> T2;
62 const T1 t1(1);
63 const T2 t2(0.9);
64 assert(!(t1 < t2));
65 assert(!(t1 <= t2));
66 assert( (t1 > t2));
67 assert( (t1 >= t2));
68 }
69 {
70 typedef std::tuple<long> T1;
71 typedef std::tuple<double> T2;
72 const T1 t1(1);
73 const T2 t2(1.1);
74 assert( (t1 < t2));
75 assert( (t1 <= t2));
76 assert(!(t1 > t2));
77 assert(!(t1 >= t2));
78 }
79 {
80 typedef std::tuple<long, int> T1;
81 typedef std::tuple<double, long> T2;
82 const T1 t1(1, 2);
83 const T2 t2(1, 2);
84 assert(!(t1 < t2));
85 assert( (t1 <= t2));
86 assert(!(t1 > t2));
87 assert( (t1 >= t2));
88 }
89 {
90 typedef std::tuple<long, int> T1;
91 typedef std::tuple<double, long> T2;
92 const T1 t1(1, 2);
93 const T2 t2(0.9, 2);
94 assert(!(t1 < t2));
95 assert(!(t1 <= t2));
96 assert( (t1 > t2));
97 assert( (t1 >= t2));
98 }
99 {
100 typedef std::tuple<long, int> T1;
101 typedef std::tuple<double, long> T2;
102 const T1 t1(1, 2);
103 const T2 t2(1.1, 2);
104 assert( (t1 < t2));
105 assert( (t1 <= t2));
106 assert(!(t1 > t2));
107 assert(!(t1 >= t2));
108 }
109 {
110 typedef std::tuple<long, int> T1;
111 typedef std::tuple<double, long> T2;
112 const T1 t1(1, 2);
113 const T2 t2(1, 1);
114 assert(!(t1 < t2));
115 assert(!(t1 <= t2));
116 assert( (t1 > t2));
117 assert( (t1 >= t2));
118 }
119 {
120 typedef std::tuple<long, int> T1;
121 typedef std::tuple<double, long> T2;
122 const T1 t1(1, 2);
123 const T2 t2(1, 3);
124 assert( (t1 < t2));
125 assert( (t1 <= t2));
126 assert(!(t1 > t2));
127 assert(!(t1 >= t2));
128 }
129 {
130 typedef std::tuple<long, int, double> T1;
131 typedef std::tuple<double, long, int> T2;
132 const T1 t1(1, 2, 3);
133 const T2 t2(1, 2, 3);
134 assert(!(t1 < t2));
135 assert( (t1 <= t2));
136 assert(!(t1 > t2));
137 assert( (t1 >= t2));
138 }
139 {
140 typedef std::tuple<long, int, double> T1;
141 typedef std::tuple<double, long, int> T2;
142 const T1 t1(1, 2, 3);
143 const T2 t2(0.9, 2, 3);
144 assert(!(t1 < t2));
145 assert(!(t1 <= t2));
146 assert( (t1 > t2));
147 assert( (t1 >= t2));
148 }
149 {
150 typedef std::tuple<long, int, double> T1;
151 typedef std::tuple<double, long, int> T2;
152 const T1 t1(1, 2, 3);
153 const T2 t2(1.1, 2, 3);
154 assert( (t1 < t2));
155 assert( (t1 <= t2));
156 assert(!(t1 > t2));
157 assert(!(t1 >= t2));
158 }
159 {
160 typedef std::tuple<long, int, double> T1;
161 typedef std::tuple<double, long, int> T2;
162 const T1 t1(1, 2, 3);
163 const T2 t2(1, 1, 3);
164 assert(!(t1 < t2));
165 assert(!(t1 <= t2));
166 assert( (t1 > t2));
167 assert( (t1 >= t2));
168 }
169 {
170 typedef std::tuple<long, int, double> T1;
171 typedef std::tuple<double, long, int> T2;
172 const T1 t1(1, 2, 3);
173 const T2 t2(1, 3, 3);
174 assert( (t1 < t2));
175 assert( (t1 <= t2));
176 assert(!(t1 > t2));
177 assert(!(t1 >= t2));
178 }
179 {
180 typedef std::tuple<long, int, double> T1;
181 typedef std::tuple<double, long, int> T2;
182 const T1 t1(1, 2, 3);
183 const T2 t2(1, 2, 2);
184 assert(!(t1 < t2));
185 assert(!(t1 <= t2));
186 assert( (t1 > t2));
187 assert( (t1 >= t2));
188 }
189 {
190 typedef std::tuple<long, int, double> T1;
191 typedef std::tuple<double, long, int> T2;
192 const T1 t1(1, 2, 3);
193 const T2 t2(1, 2, 4);
194 assert( (t1 < t2));
195 assert( (t1 <= t2));
196 assert(!(t1 > t2));
197 assert(!(t1 >= t2));
198 }
199#if TEST_STD_VER > 11
200 {
201 typedef std::tuple<long, int, double> T1;
202 typedef std::tuple<double, long, int> T2;
203 constexpr T1 t1(1, 2, 3);
204 constexpr T2 t2(1, 2, 4);
205 static_assert( (t1 < t2), "");
206 static_assert( (t1 <= t2), "");
207 static_assert(!(t1 > t2), "");
208 static_assert(!(t1 >= t2), "");
209 }
210#endif
211
212 return 0;
213}
214

source code of libcxx/test/std/utilities/tuple/tuple.tuple/tuple.rel/lt.pass.cpp