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 #include <tuple>
     17 #include <string>
     18 #include <cassert>
     19 
     20 struct Empty {};
     21 
     22 int main()
     23 {
     24     {
     25         typedef std::tuple<> T;
     26         T t0;
     27         T t = t0;
     28     }
     29     {
     30         typedef std::tuple<int> T;
     31         T t0(2);
     32         T t = t0;
     33         assert(std::get<0>(t) == 2);
     34     }
     35     {
     36         typedef std::tuple<int, char> T;
     37         T t0(2, 'a');
     38         T t = t0;
     39         assert(std::get<0>(t) == 2);
     40         assert(std::get<1>(t) == 'a');
     41     }
     42     {
     43         typedef std::tuple<int, char, std::string> T;
     44         const T t0(2, 'a', "some text");
     45         T t = t0;
     46         assert(std::get<0>(t) == 2);
     47         assert(std::get<1>(t) == 'a');
     48         assert(std::get<2>(t) == "some text");
     49     }
     50 #if _LIBCPP_STD_VER > 11
     51     {
     52         typedef std::tuple<int> T;
     53         constexpr T t0(2);
     54         constexpr T t = t0;
     55         static_assert(std::get<0>(t) == 2, "");
     56     }
     57     {
     58         typedef std::tuple<Empty> T;
     59         constexpr T t0;
     60         constexpr T t = t0;
     61     }
     62 #endif
     63 }
     64