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 // UNSUPPORTED: c++98, c++03
19 
20 #include <tuple>
21 #include <string>
22 #include <cassert>
23 
24 #include "test_macros.h"
25 
main()26 int main()
27 {
28     {
29         typedef std::tuple<> T1;
30         typedef std::tuple<> T2;
31         const T1 t1;
32         const T2 t2;
33         assert(t1 == t2);
34         assert(!(t1 != t2));
35     }
36     {
37         typedef std::tuple<int> T1;
38         typedef std::tuple<double> T2;
39         const T1 t1(1);
40         const T2 t2(1.1);
41         assert(!(t1 == t2));
42         assert(t1 != t2);
43     }
44     {
45         typedef std::tuple<int> T1;
46         typedef std::tuple<double> T2;
47         const T1 t1(1);
48         const T2 t2(1);
49         assert(t1 == t2);
50         assert(!(t1 != t2));
51     }
52     {
53         typedef std::tuple<int, double> T1;
54         typedef std::tuple<double, long> T2;
55         const T1 t1(1, 2);
56         const T2 t2(1, 2);
57         assert(t1 == t2);
58         assert(!(t1 != t2));
59     }
60     {
61         typedef std::tuple<int, double> T1;
62         typedef std::tuple<double, long> T2;
63         const T1 t1(1, 2);
64         const T2 t2(1, 3);
65         assert(!(t1 == t2));
66         assert(t1 != t2);
67     }
68     {
69         typedef std::tuple<int, double> T1;
70         typedef std::tuple<double, long> T2;
71         const T1 t1(1, 2);
72         const T2 t2(1.1, 2);
73         assert(!(t1 == t2));
74         assert(t1 != t2);
75     }
76     {
77         typedef std::tuple<int, double> T1;
78         typedef std::tuple<double, long> T2;
79         const T1 t1(1, 2);
80         const T2 t2(1.1, 3);
81         assert(!(t1 == t2));
82         assert(t1 != t2);
83     }
84     {
85         typedef std::tuple<long, int, double> T1;
86         typedef std::tuple<double, long, int> T2;
87         const T1 t1(1, 2, 3);
88         const T2 t2(1, 2, 3);
89         assert(t1 == t2);
90         assert(!(t1 != t2));
91     }
92     {
93         typedef std::tuple<long, int, double> T1;
94         typedef std::tuple<double, long, int> T2;
95         const T1 t1(1, 2, 3);
96         const T2 t2(1.1, 2, 3);
97         assert(!(t1 == t2));
98         assert(t1 != t2);
99     }
100     {
101         typedef std::tuple<long, int, double> T1;
102         typedef std::tuple<double, long, int> T2;
103         const T1 t1(1, 2, 3);
104         const T2 t2(1, 3, 3);
105         assert(!(t1 == t2));
106         assert(t1 != t2);
107     }
108     {
109         typedef std::tuple<long, int, double> T1;
110         typedef std::tuple<double, long, int> T2;
111         const T1 t1(1, 2, 3);
112         const T2 t2(1, 2, 4);
113         assert(!(t1 == t2));
114         assert(t1 != t2);
115     }
116     {
117         typedef std::tuple<long, int, double> T1;
118         typedef std::tuple<double, long, int> T2;
119         const T1 t1(1, 2, 3);
120         const T2 t2(1, 3, 2);
121         assert(!(t1 == t2));
122         assert(t1 != t2);
123     }
124     {
125         typedef std::tuple<long, int, double> T1;
126         typedef std::tuple<double, long, int> T2;
127         const T1 t1(1, 2, 3);
128         const T2 t2(1.1, 2, 2);
129         assert(!(t1 == t2));
130         assert(t1 != t2);
131     }
132     {
133         typedef std::tuple<long, int, double> T1;
134         typedef std::tuple<double, long, int> T2;
135         const T1 t1(1, 2, 3);
136         const T2 t2(1.1, 3, 3);
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(1.1, 3, 2);
145         assert(!(t1 == t2));
146         assert(t1 != t2);
147     }
148 #if TEST_STD_VER > 11
149     {
150         typedef std::tuple<long, int, double> T1;
151         typedef std::tuple<double, long, int> T2;
152         constexpr T1 t1(1, 2, 3);
153         constexpr T2 t2(1.1, 3, 2);
154         static_assert(!(t1 == t2), "");
155         static_assert(t1 != t2, "");
156     }
157 #endif
158 }
159