//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // template // requires HasSwap // Iter2 // swap_ranges(Iter1 first1, Iter1 last1, Iter2 first2); #include #include #ifdef _LIBCPP_MOVE #include #endif #include "../../iterators.h" template void test() { int i[3] = {1, 2, 3}; int j[3] = {4, 5, 6}; Iter2 r = std::swap_ranges(Iter1(i), Iter1(i+3), Iter2(j)); assert(base(r) == j+3); assert(i[0] == 4); assert(i[1] == 5); assert(i[2] == 6); assert(j[0] == 1); assert(j[1] == 2); assert(j[2] == 3); } #ifdef _LIBCPP_MOVE template void test1() { std::unique_ptr i[3]; for (int k = 0; k < 3; ++k) i[k].reset(new int(k+1)); std::unique_ptr j[3]; for (int k = 0; k < 3; ++k) j[k].reset(new int(k+4)); Iter2 r = std::swap_ranges(Iter1(i), Iter1(i+3), Iter2(j)); assert(base(r) == j+3); assert(*i[0] == 4); assert(*i[1] == 5); assert(*i[2] == 6); assert(*j[0] == 1); assert(*j[1] == 2); assert(*j[2] == 3); } #endif // _LIBCPP_MOVE int main() { test, forward_iterator >(); test, bidirectional_iterator >(); test, random_access_iterator >(); test, int*>(); test, forward_iterator >(); test, bidirectional_iterator >(); test, random_access_iterator >(); test, int*>(); test, forward_iterator >(); test, bidirectional_iterator >(); test, random_access_iterator >(); test, int*>(); test >(); test >(); test >(); test(); #ifdef _LIBCPP_MOVE test1*>, forward_iterator*> >(); test1*>, bidirectional_iterator*> >(); test1*>, random_access_iterator*> >(); test1*>, std::unique_ptr*>(); test1*>, forward_iterator*> >(); test1*>, bidirectional_iterator*> >(); test1*>, random_access_iterator*> >(); test1*>, std::unique_ptr*>(); test1*>, forward_iterator*> >(); test1*>, bidirectional_iterator*> >(); test1*>, random_access_iterator*> >(); test1*>, std::unique_ptr*>(); test1*, forward_iterator*> >(); test1*, bidirectional_iterator*> >(); test1*, random_access_iterator*> >(); test1*, std::unique_ptr*>(); #endif // _LIBCPP_MOVE }