Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1 | //===----------------------------------------------------------------------===// |
| 2 | // |
Howard Hinnant | f5256e1 | 2010-05-11 21:36:01 +0000 | [diff] [blame] | 3 | // The LLVM Compiler Infrastructure |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4 | // |
Howard Hinnant | b64f8b0 | 2010-11-16 22:09:02 +0000 | [diff] [blame] | 5 | // This file is dual licensed under the MIT and the University of Illinois Open |
| 6 | // Source Licenses. See LICENSE.TXT for details. |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | // <tuple> |
| 11 | |
| 12 | // template <class... Types> class tuple; |
| 13 | |
| 14 | // template <class Alloc, class... UTypes> |
| 15 | // tuple(allocator_arg_t, const Alloc& a, const tuple<UTypes...>&); |
| 16 | |
Eric Fiselier | f063052 | 2015-02-19 02:10:42 +0000 | [diff] [blame] | 17 | // UNSUPPORTED: c++98, c++03 |
| 18 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 19 | #include <tuple> |
| 20 | #include <cassert> |
| 21 | |
Marshall Clow | ebedffd | 2013-12-02 18:08:31 +0000 | [diff] [blame] | 22 | #include "allocators.h" |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 23 | #include "../alloc_first.h" |
| 24 | #include "../alloc_last.h" |
| 25 | |
| 26 | int main() |
| 27 | { |
| 28 | { |
| 29 | typedef std::tuple<double> T0; |
| 30 | typedef std::tuple<int> T1; |
| 31 | T0 t0(2.5); |
| 32 | T1 t1(std::allocator_arg, A1<int>(), t0); |
| 33 | assert(std::get<0>(t1) == 2); |
| 34 | } |
| 35 | { |
| 36 | typedef std::tuple<int> T0; |
| 37 | typedef std::tuple<alloc_first> T1; |
| 38 | T0 t0(2); |
| 39 | alloc_first::allocator_constructed = false; |
| 40 | T1 t1(std::allocator_arg, A1<int>(5), t0); |
| 41 | assert(alloc_first::allocator_constructed); |
| 42 | assert(std::get<0>(t1) == 2); |
| 43 | } |
| 44 | { |
| 45 | typedef std::tuple<int, int> T0; |
| 46 | typedef std::tuple<alloc_first, alloc_last> T1; |
| 47 | T0 t0(2, 3); |
| 48 | alloc_first::allocator_constructed = false; |
| 49 | alloc_last::allocator_constructed = false; |
| 50 | T1 t1(std::allocator_arg, A1<int>(5), t0); |
| 51 | assert(alloc_first::allocator_constructed); |
| 52 | assert(alloc_last::allocator_constructed); |
| 53 | assert(std::get<0>(t1) == 2); |
| 54 | assert(std::get<1>(t1) == 3); |
| 55 | } |
| 56 | { |
| 57 | typedef std::tuple<double, int, int> T0; |
| 58 | typedef std::tuple<int, alloc_first, alloc_last> T1; |
| 59 | T0 t0(1.5, 2, 3); |
| 60 | alloc_first::allocator_constructed = false; |
| 61 | alloc_last::allocator_constructed = false; |
| 62 | T1 t1(std::allocator_arg, A1<int>(5), t0); |
| 63 | assert(alloc_first::allocator_constructed); |
| 64 | assert(alloc_last::allocator_constructed); |
| 65 | assert(std::get<0>(t1) == 1); |
| 66 | assert(std::get<1>(t1) == 2); |
| 67 | assert(std::get<2>(t1) == 3); |
| 68 | } |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 69 | } |