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