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... Types> 15 // void swap(tuple<Types...>& x, tuple<Types...>& y); 16 17 // UNSUPPORTED: c++98, c++03 18 19 #include <tuple> 20 #include <cassert> 21 22 #include "MoveOnly.h" 23 24 int main() 25 { 26 { 27 typedef std::tuple<> T; 28 T t0; 29 T t1; 30 swap(t0, t1); 31 } 32 { 33 typedef std::tuple<MoveOnly> T; 34 T t0(MoveOnly(0)); 35 T t1(MoveOnly(1)); 36 swap(t0, t1); 37 assert(std::get<0>(t0) == 1); 38 assert(std::get<0>(t1) == 0); 39 } 40 { 41 typedef std::tuple<MoveOnly, MoveOnly> T; 42 T t0(MoveOnly(0), MoveOnly(1)); 43 T t1(MoveOnly(2), MoveOnly(3)); 44 swap(t0, t1); 45 assert(std::get<0>(t0) == 2); 46 assert(std::get<1>(t0) == 3); 47 assert(std::get<0>(t1) == 0); 48 assert(std::get<1>(t1) == 1); 49 } 50 { 51 typedef std::tuple<MoveOnly, MoveOnly, MoveOnly> T; 52 T t0(MoveOnly(0), MoveOnly(1), MoveOnly(2)); 53 T t1(MoveOnly(3), MoveOnly(4), MoveOnly(5)); 54 swap(t0, t1); 55 assert(std::get<0>(t0) == 3); 56 assert(std::get<1>(t0) == 4); 57 assert(std::get<2>(t0) == 5); 58 assert(std::get<0>(t1) == 0); 59 assert(std::get<1>(t1) == 1); 60 assert(std::get<2>(t1) == 2); 61 } 62 } 63