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 // template <class Alloc>
     15 //   tuple(allocator_arg_t, const Alloc& a, const Types&...);
     16 
     17 #include <tuple>
     18 #include <cassert>
     19 
     20 #include "allocators.h"
     21 #include "../alloc_first.h"
     22 #include "../alloc_last.h"
     23 
     24 int main()
     25 {
     26     {
     27         std::tuple<int> t(std::allocator_arg, A1<int>(), 3);
     28         assert(std::get<0>(t) == 3);
     29     }
     30     {
     31         assert(!alloc_first::allocator_constructed);
     32         std::tuple<alloc_first> t(std::allocator_arg, A1<int>(5), alloc_first(3));
     33         assert(alloc_first::allocator_constructed);
     34         assert(std::get<0>(t) == alloc_first(3));
     35     }
     36     {
     37         assert(!alloc_last::allocator_constructed);
     38         std::tuple<alloc_last> t(std::allocator_arg, A1<int>(5), alloc_last(3));
     39         assert(alloc_last::allocator_constructed);
     40         assert(std::get<0>(t) == alloc_last(3));
     41     }
     42     {
     43         alloc_first::allocator_constructed = false;
     44         std::tuple<int, alloc_first> t(std::allocator_arg, A1<int>(5),
     45                                        10, alloc_first(15));
     46         assert(std::get<0>(t) == 10);
     47         assert(alloc_first::allocator_constructed);
     48         assert(std::get<1>(t) == alloc_first(15));
     49     }
     50     {
     51         alloc_first::allocator_constructed = false;
     52         alloc_last::allocator_constructed = false;
     53         std::tuple<int, alloc_first, alloc_last> t(std::allocator_arg,
     54                                                    A1<int>(5), 1, alloc_first(2),
     55                                                    alloc_last(3));
     56         assert(std::get<0>(t) == 1);
     57         assert(alloc_first::allocator_constructed);
     58         assert(std::get<1>(t) == alloc_first(2));
     59         assert(alloc_last::allocator_constructed);
     60         assert(std::get<2>(t) == alloc_last(3));
     61     }
     62     {
     63         alloc_first::allocator_constructed = false;
     64         alloc_last::allocator_constructed = false;
     65         std::tuple<int, alloc_first, alloc_last> t(std::allocator_arg,
     66                                                    A2<int>(5), 1, alloc_first(2),
     67                                                    alloc_last(3));
     68         assert(std::get<0>(t) == 1);
     69         assert(!alloc_first::allocator_constructed);
     70         assert(std::get<1>(t) == alloc_first(2));
     71         assert(!alloc_last::allocator_constructed);
     72         assert(std::get<2>(t) == alloc_last(3));
     73     }
     74 }
     75