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> |
| 15 | // tuple(allocator_arg_t, const Alloc& a); |
| 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 | e27dbcf | 2013-12-02 17:00:56 +0000 | [diff] [blame] | 22 | #include "DefaultOnly.h" |
Marshall Clow | ebedffd | 2013-12-02 18:08:31 +0000 | [diff] [blame] | 23 | #include "allocators.h" |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 24 | #include "../alloc_first.h" |
| 25 | #include "../alloc_last.h" |
| 26 | |
| 27 | int main() |
| 28 | { |
| 29 | { |
| 30 | std::tuple<> t(std::allocator_arg, A1<int>()); |
| 31 | } |
| 32 | { |
| 33 | std::tuple<int> t(std::allocator_arg, A1<int>()); |
| 34 | assert(std::get<0>(t) == 0); |
| 35 | } |
| 36 | { |
| 37 | std::tuple<DefaultOnly> t(std::allocator_arg, A1<int>()); |
| 38 | assert(std::get<0>(t) == DefaultOnly()); |
| 39 | } |
| 40 | { |
| 41 | assert(!alloc_first::allocator_constructed); |
| 42 | std::tuple<alloc_first> t(std::allocator_arg, A1<int>(5)); |
| 43 | assert(alloc_first::allocator_constructed); |
| 44 | assert(std::get<0>(t) == alloc_first()); |
| 45 | } |
| 46 | { |
| 47 | assert(!alloc_last::allocator_constructed); |
| 48 | std::tuple<alloc_last> t(std::allocator_arg, A1<int>(5)); |
| 49 | assert(alloc_last::allocator_constructed); |
| 50 | assert(std::get<0>(t) == alloc_last()); |
| 51 | } |
| 52 | { |
| 53 | alloc_first::allocator_constructed = false; |
| 54 | std::tuple<DefaultOnly, alloc_first> t(std::allocator_arg, A1<int>(5)); |
| 55 | assert(std::get<0>(t) == DefaultOnly()); |
| 56 | assert(alloc_first::allocator_constructed); |
| 57 | assert(std::get<1>(t) == alloc_first()); |
| 58 | } |
| 59 | { |
| 60 | alloc_first::allocator_constructed = false; |
| 61 | alloc_last::allocator_constructed = false; |
| 62 | std::tuple<DefaultOnly, alloc_first, alloc_last> t(std::allocator_arg, |
| 63 | A1<int>(5)); |
| 64 | assert(std::get<0>(t) == DefaultOnly()); |
| 65 | assert(alloc_first::allocator_constructed); |
| 66 | assert(std::get<1>(t) == alloc_first()); |
| 67 | assert(alloc_last::allocator_constructed); |
| 68 | assert(std::get<2>(t) == alloc_last()); |
| 69 | } |
| 70 | { |
| 71 | alloc_first::allocator_constructed = false; |
| 72 | alloc_last::allocator_constructed = false; |
| 73 | std::tuple<DefaultOnly, alloc_first, alloc_last> t(std::allocator_arg, |
| 74 | A2<int>(5)); |
| 75 | assert(std::get<0>(t) == DefaultOnly()); |
| 76 | assert(!alloc_first::allocator_constructed); |
| 77 | assert(std::get<1>(t) == alloc_first()); |
| 78 | assert(!alloc_last::allocator_constructed); |
| 79 | assert(std::get<2>(t) == alloc_last()); |
| 80 | } |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 81 | } |