Home | History | Annotate | Download | only in tuple.cnstr
      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 // tuple(const tuple& u) = default;
     15 
     16 // UNSUPPORTED: c++98, c++03
     17 
     18 #include <tuple>
     19 #include <string>
     20 #include <cassert>
     21 
     22 struct Empty {};
     23 
     24 int main()
     25 {
     26     {
     27         typedef std::tuple<> T;
     28         T t0;
     29         T t = t0;
     30         ((void)t); // Prevent unused warning
     31     }
     32     {
     33         typedef std::tuple<int> T;
     34         T t0(2);
     35         T t = t0;
     36         assert(std::get<0>(t) == 2);
     37     }
     38     {
     39         typedef std::tuple<int, char> T;
     40         T t0(2, 'a');
     41         T t = t0;
     42         assert(std::get<0>(t) == 2);
     43         assert(std::get<1>(t) == 'a');
     44     }
     45     {
     46         typedef std::tuple<int, char, std::string> T;
     47         const T t0(2, 'a', "some text");
     48         T t = t0;
     49         assert(std::get<0>(t) == 2);
     50         assert(std::get<1>(t) == 'a');
     51         assert(std::get<2>(t) == "some text");
     52     }
     53 #if _LIBCPP_STD_VER > 11
     54     {
     55         typedef std::tuple<int> T;
     56         constexpr T t0(2);
     57         constexpr T t = t0;
     58         static_assert(std::get<0>(t) == 2, "");
     59     }
     60     {
     61         typedef std::tuple<Empty> T;
     62         constexpr T t0;
     63         constexpr T t = t0;
     64         constexpr Empty e = std::get<0>(t);
     65         ((void)e); // Prevent unused warning
     66     }
     67 #endif
     68 }
     69