alloc_UTypes.pass.cpp revision f5256e16dfc425c1d466f6308d4026d529ce9e0b
1//===----------------------------------------------------------------------===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 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, UTypes&&...); 16 17#include <tuple> 18#include <cassert> 19 20#include "../MoveOnly.h" 21#include "../allocators.h" 22#include "../alloc_first.h" 23#include "../alloc_last.h" 24 25int main() 26{ 27 { 28 std::tuple<MoveOnly> t(std::allocator_arg, A1<int>(), MoveOnly(0)); 29 assert(std::get<0>(t) == 0); 30 } 31 { 32 std::tuple<MoveOnly, MoveOnly> t(std::allocator_arg, A1<int>(), 33 MoveOnly(0), MoveOnly(1)); 34 assert(std::get<0>(t) == 0); 35 assert(std::get<1>(t) == 1); 36 } 37 { 38 std::tuple<MoveOnly, MoveOnly, MoveOnly> t(std::allocator_arg, A1<int>(), 39 MoveOnly(0), 40 1, 2); 41 assert(std::get<0>(t) == 0); 42 assert(std::get<1>(t) == 1); 43 assert(std::get<2>(t) == 2); 44 } 45 { 46 alloc_first::allocator_constructed = false; 47 alloc_last::allocator_constructed = false; 48 std::tuple<int, alloc_first, alloc_last> t(std::allocator_arg, 49 A1<int>(5), 1, 2, 3); 50 assert(std::get<0>(t) == 1); 51 assert(alloc_first::allocator_constructed); 52 assert(std::get<1>(t) == alloc_first(2)); 53 assert(alloc_last::allocator_constructed); 54 assert(std::get<2>(t) == alloc_last(3)); 55 } 56 // extensions 57 { 58 std::tuple<MoveOnly, MoveOnly, MoveOnly> t(std::allocator_arg, A1<int>(), 59 0, 1); 60 assert(std::get<0>(t) == 0); 61 assert(std::get<1>(t) == 1); 62 assert(std::get<2>(t) == MoveOnly()); 63 } 64 { 65 std::tuple<MoveOnly, MoveOnly, MoveOnly> t(std::allocator_arg, A1<int>(), 66 0); 67 assert(std::get<0>(t) == 0); 68 assert(std::get<1>(t) == MoveOnly()); 69 assert(std::get<2>(t) == MoveOnly()); 70 } 71} 72