1 ////////////////////////////////////////////////////////////////////////////// 2 // 3 // (C) Copyright Ion Gaztanaga 2009. 4 // Distributed under the Boost Software License, Version 1.0. 5 // (See accompanying file LICENSE_1_0.txt or copy at 6 // http://www.boost.org/LICENSE_1_0.txt) 7 // 8 // See http://www.boost.org/libs/move for documentation. 9 // 10 ////////////////////////////////////////////////////////////////////////////// 11 12 //[move_algorithms_example 13 #include "movable.hpp" 14 #include <boost/move/algorithm.hpp> 15 #include <cassert> 16 #include <boost/aligned_storage.hpp> 17 main()18int main() 19 { 20 const std::size_t ArraySize = 10; 21 movable movable_array[ArraySize]; 22 movable movable_array2[ArraySize]; 23 //move 24 boost::move(&movable_array2[0], &movable_array2[ArraySize], &movable_array[0]); 25 assert(movable_array2[0].moved()); 26 assert(!movable_array[0].moved()); 27 28 //move backward 29 boost::move_backward(&movable_array[0], &movable_array[ArraySize], &movable_array2[ArraySize]); 30 assert(movable_array[0].moved()); 31 assert(!movable_array2[0].moved()); 32 33 //uninitialized_move 34 boost::aligned_storage< sizeof(movable)*ArraySize 35 , boost::alignment_of<movable>::value>::type storage; 36 movable *raw_movable = static_cast<movable*>(static_cast<void*>(&storage)); 37 boost::uninitialized_move(&movable_array2[0], &movable_array2[ArraySize], raw_movable); 38 assert(movable_array2[0].moved()); 39 assert(!raw_movable[0].moved()); 40 return 0; 41 } 42 //] 43 44