1*4684ddb6SLionel Sambuc //===----------------------------------------------------------------------===// 2*4684ddb6SLionel Sambuc // 3*4684ddb6SLionel Sambuc // The LLVM Compiler Infrastructure 4*4684ddb6SLionel Sambuc // 5*4684ddb6SLionel Sambuc // This file is dual licensed under the MIT and the University of Illinois Open 6*4684ddb6SLionel Sambuc // Source Licenses. See LICENSE.TXT for details. 7*4684ddb6SLionel Sambuc // 8*4684ddb6SLionel Sambuc //===----------------------------------------------------------------------===// 9*4684ddb6SLionel Sambuc 10*4684ddb6SLionel Sambuc // <utility> 11*4684ddb6SLionel Sambuc 12*4684ddb6SLionel Sambuc // template<class T> 13*4684ddb6SLionel Sambuc // requires MoveAssignable<T> && MoveConstructible<T> 14*4684ddb6SLionel Sambuc // void 15*4684ddb6SLionel Sambuc // swap(T& a, T& b); 16*4684ddb6SLionel Sambuc 17*4684ddb6SLionel Sambuc #include <utility> 18*4684ddb6SLionel Sambuc #include <cassert> 19*4684ddb6SLionel Sambuc #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 20*4684ddb6SLionel Sambuc #include <memory> 21*4684ddb6SLionel Sambuc #endif 22*4684ddb6SLionel Sambuc 23*4684ddb6SLionel Sambuc void test()24*4684ddb6SLionel Sambuctest() 25*4684ddb6SLionel Sambuc { 26*4684ddb6SLionel Sambuc int i = 1; 27*4684ddb6SLionel Sambuc int j = 2; 28*4684ddb6SLionel Sambuc std::swap(i, j); 29*4684ddb6SLionel Sambuc assert(i == 2); 30*4684ddb6SLionel Sambuc assert(j == 1); 31*4684ddb6SLionel Sambuc } 32*4684ddb6SLionel Sambuc 33*4684ddb6SLionel Sambuc #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 34*4684ddb6SLionel Sambuc 35*4684ddb6SLionel Sambuc void test1()36*4684ddb6SLionel Sambuctest1() 37*4684ddb6SLionel Sambuc { 38*4684ddb6SLionel Sambuc std::unique_ptr<int> i(new int(1)); 39*4684ddb6SLionel Sambuc std::unique_ptr<int> j(new int(2)); 40*4684ddb6SLionel Sambuc std::swap(i, j); 41*4684ddb6SLionel Sambuc assert(*i == 2); 42*4684ddb6SLionel Sambuc assert(*j == 1); 43*4684ddb6SLionel Sambuc } 44*4684ddb6SLionel Sambuc 45*4684ddb6SLionel Sambuc #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 46*4684ddb6SLionel Sambuc main()47*4684ddb6SLionel Sambucint main() 48*4684ddb6SLionel Sambuc { 49*4684ddb6SLionel Sambuc test(); 50*4684ddb6SLionel Sambuc #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 51*4684ddb6SLionel Sambuc test1(); 52*4684ddb6SLionel Sambuc #endif 53*4684ddb6SLionel Sambuc } 54