////////////////////////////////////////////////////////////////////////////// // // (C) Copyright Ion Gaztanaga 2012-2016. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // // See http://www.boost.org/libs/move for documentation. // ////////////////////////////////////////////////////////////////////////////// //! \file #ifndef BOOST_MOVE_ALGO_MOVE_HPP #define BOOST_MOVE_ALGO_MOVE_HPP #ifndef BOOST_CONFIG_HPP # include #endif # #if defined(BOOST_HAS_PRAGMA_ONCE) # pragma once #endif #include #include #include #include #include namespace boost { ////////////////////////////////////////////////////////////////////////////// // // move // ////////////////////////////////////////////////////////////////////////////// #if !defined(BOOST_MOVE_USE_STANDARD_LIBRARY_MOVE) //! Effects: Moves elements in the range [first,last) into the range [result,result + (last - //! first)) starting from first and proceeding to last. For each non-negative integer n < (last-first), //! performs *(result + n) = ::boost::move (*(first + n)). //! //! Effects: result + (last - first). //! //! Requires: result shall not be in the range [first,last). //! //! Complexity: Exactly last - first move assignments. template // O models OutputIterator O move(I f, I l, O result) { while (f != l) { *result = ::boost::move(*f); ++f; ++result; } return result; } ////////////////////////////////////////////////////////////////////////////// // // move_backward // ////////////////////////////////////////////////////////////////////////////// //! Effects: Moves elements in the range [first,last) into the range //! [result - (last-first),result) starting from last - 1 and proceeding to //! first. For each positive integer n <= (last - first), //! performs *(result - n) = ::boost::move(*(last - n)). //! //! Requires: result shall not be in the range [first,last). //! //! Returns: result - (last - first). //! //! Complexity: Exactly last - first assignments. template // O models BidirectionalIterator O move_backward(I f, I l, O result) { while (f != l) { --l; --result; *result = ::boost::move(*l); } return result; } #else using ::std::move_backward; #endif //!defined(BOOST_MOVE_USE_STANDARD_LIBRARY_MOVE) ////////////////////////////////////////////////////////////////////////////// // // uninitialized_move // ////////////////////////////////////////////////////////////////////////////// //! Effects: //! \code //! for (; first != last; ++result, ++first) //! new (static_cast(&*result)) //! typename iterator_traits::value_type(boost::move(*first)); //! \endcode //! //! Returns: result template // F models ForwardIterator F uninitialized_move(I f, I l, F r /// @cond // ,typename ::boost::move_detail::enable_if::value_type> >::type* = 0 /// @endcond ) { typedef typename boost::movelib::iterator_traits::value_type input_value_type; F back = r; BOOST_TRY{ while (f != l) { void * const addr = static_cast(::boost::move_detail::addressof(*r)); ::new(addr) input_value_type(::boost::move(*f)); ++f; ++r; } } BOOST_CATCH(...){ for (; back != r; ++back){ boost::movelib::iterator_to_raw_pointer(back)->~input_value_type(); } BOOST_RETHROW; } BOOST_CATCH_END return r; } /// @cond /* template // F models ForwardIterator F uninitialized_move(I f, I l, F r, typename ::boost::move_detail::disable_if::value_type> >::type* = 0) { return std::uninitialized_copy(f, l, r); } */ /// @endcond } //namespace boost { #include #endif //#ifndef BOOST_MOVE_ALGO_MOVE_HPP