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 #include <boost/move/detail/config_begin.hpp> 13 14 //[move_algorithms_example 15 #include "movable.hpp" 16 #include <boost/move/algorithm.hpp> 17 #include <cassert> 18 #include <boost/aligned_storage.hpp> 19 main()20int main() 21 { 22 const std::size_t ArraySize = 10; 23 movable movable_array[ArraySize]; 24 movable movable_array2[ArraySize]; 25 //move 26 boost::move(&movable_array2[0], &movable_array2[ArraySize], &movable_array[0]); 27 assert(movable_array2[0].moved()); 28 assert(!movable_array[0].moved()); 29 30 //move backward 31 boost::move_backward(&movable_array[0], &movable_array[ArraySize], &movable_array2[ArraySize]); 32 assert(movable_array[0].moved()); 33 assert(!movable_array2[0].moved()); 34 35 //uninitialized_move 36 boost::aligned_storage< sizeof(movable)*ArraySize 37 , boost::alignment_of<movable>::value>::type storage; 38 movable *raw_movable = static_cast<movable*>(static_cast<void*>(&storage)); 39 boost::uninitialized_move(&movable_array2[0], &movable_array2[ArraySize], raw_movable); 40 assert(movable_array2[0].moved()); 41 assert(!raw_movable[0].moved()); 42 return 0; 43 } 44 //] 45 46 #include <boost/move/detail/config_end.hpp> 47