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