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