libcxx

libcxx mirror with random patches
git clone https://git.neptards.moe/neptards/libcxx.git
Log | Files | Refs

alloc_copy.pass.cpp (2365B)


      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 tuple&);
     16 
     17 // UNSUPPORTED: c++98, c++03
     18 
     19 #include <tuple>
     20 #include <cassert>
     21 
     22 #include "allocators.h"
     23 #include "../alloc_first.h"
     24 #include "../alloc_last.h"
     25 
     26 int main()
     27 {
     28     {
     29         typedef std::tuple<> T;
     30         T t0;
     31         T t(std::allocator_arg, A1<int>(), t0);
     32     }
     33     {
     34         typedef std::tuple<int> T;
     35         T t0(2);
     36         T t(std::allocator_arg, A1<int>(), t0);
     37         assert(std::get<0>(t) == 2);
     38     }
     39     {
     40         typedef std::tuple<alloc_first> T;
     41         T t0(2);
     42         alloc_first::allocator_constructed = false;
     43         T t(std::allocator_arg, A1<int>(5), t0);
     44         assert(alloc_first::allocator_constructed);
     45         assert(std::get<0>(t) == 2);
     46     }
     47     {
     48         typedef std::tuple<alloc_last> T;
     49         T t0(2);
     50         alloc_last::allocator_constructed = false;
     51         T t(std::allocator_arg, A1<int>(5), t0);
     52         assert(alloc_last::allocator_constructed);
     53         assert(std::get<0>(t) == 2);
     54     }
     55 // testing extensions
     56 #ifdef _LIBCPP_VERSION
     57     {
     58         typedef std::tuple<alloc_first, alloc_last> T;
     59         T t0(2, 3);
     60         alloc_first::allocator_constructed = false;
     61         alloc_last::allocator_constructed = false;
     62         T t(std::allocator_arg, A1<int>(5), t0);
     63         assert(alloc_first::allocator_constructed);
     64         assert(alloc_last::allocator_constructed);
     65         assert(std::get<0>(t) == 2);
     66         assert(std::get<1>(t) == 3);
     67     }
     68     {
     69         typedef std::tuple<int, alloc_first, alloc_last> T;
     70         T t0(1, 2, 3);
     71         alloc_first::allocator_constructed = false;
     72         alloc_last::allocator_constructed = false;
     73         T t(std::allocator_arg, A1<int>(5), t0);
     74         assert(alloc_first::allocator_constructed);
     75         assert(alloc_last::allocator_constructed);
     76         assert(std::get<0>(t) == 1);
     77         assert(std::get<1>(t) == 2);
     78         assert(std::get<2>(t) == 3);
     79     }
     80 #endif
     81 }