1 //////////////////////////////////////////////////////////////////////////////
3 // (C) Copyright Ion Gaztanaga 2012-2016.
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)
8 // See http://www.boost.org/libs/move for documentation.
10 //////////////////////////////////////////////////////////////////////////////
14 #ifndef BOOST_MOVE_ALGO_MOVE_HPP
15 #define BOOST_MOVE_ALGO_MOVE_HPP
17 #ifndef BOOST_CONFIG_HPP
18 # include <boost/config.hpp>
21 #if defined(BOOST_HAS_PRAGMA_ONCE)
25 #include <boost/move/detail/config_begin.hpp>
27 #include <boost/move/utility_core.hpp>
28 #include <boost/move/detail/iterator_traits.hpp>
29 #include <boost/move/detail/iterator_to_raw_pointer.hpp>
30 #include <boost/core/no_exceptions_support.hpp>
34 //////////////////////////////////////////////////////////////////////////////
38 //////////////////////////////////////////////////////////////////////////////
40 #if !defined(BOOST_MOVE_USE_STANDARD_LIBRARY_MOVE)
42 //! <b>Effects</b>: Moves elements in the range [first,last) into the range [result,result + (last -
43 //! first)) starting from first and proceeding to last. For each non-negative integer n < (last-first),
44 //! performs *(result + n) = ::boost::move (*(first + n)).
46 //! <b>Effects</b>: result + (last - first).
48 //! <b>Requires</b>: result shall not be in the range [first,last).
50 //! <b>Complexity</b>: Exactly last - first move assignments.
51 template <typename I, // I models InputIterator
52 typename O> // O models OutputIterator
53 O move(I f, I l, O result)
56 *result = ::boost::move(*f);
62 //////////////////////////////////////////////////////////////////////////////
66 //////////////////////////////////////////////////////////////////////////////
68 //! <b>Effects</b>: Moves elements in the range [first,last) into the range
69 //! [result - (last-first),result) starting from last - 1 and proceeding to
70 //! first. For each positive integer n <= (last - first),
71 //! performs *(result - n) = ::boost::move(*(last - n)).
73 //! <b>Requires</b>: result shall not be in the range [first,last).
75 //! <b>Returns</b>: result - (last - first).
77 //! <b>Complexity</b>: Exactly last - first assignments.
78 template <typename I, // I models BidirectionalIterator
79 typename O> // O models BidirectionalIterator
80 O move_backward(I f, I l, O result)
84 *result = ::boost::move(*l);
91 using ::std::move_backward;
93 #endif //!defined(BOOST_MOVE_USE_STANDARD_LIBRARY_MOVE)
95 //////////////////////////////////////////////////////////////////////////////
99 //////////////////////////////////////////////////////////////////////////////
103 //! for (; first != last; ++result, ++first)
104 //! new (static_cast<void*>(&*result))
105 //! typename iterator_traits<ForwardIterator>::value_type(boost::move(*first));
108 //! <b>Returns</b>: result
110 <typename I, // I models InputIterator
111 typename F> // F models ForwardIterator
112 F uninitialized_move(I f, I l, F r
114 // ,typename ::boost::move_detail::enable_if<has_move_emulation_enabled<typename boost::movelib::iterator_traits<I>::value_type> >::type* = 0
118 typedef typename boost::movelib::iterator_traits<I>::value_type input_value_type;
123 void * const addr = static_cast<void*>(::boost::move_detail::addressof(*r));
124 ::new(addr) input_value_type(::boost::move(*f));
129 for (; back != r; ++back){
130 boost::movelib::iterator_to_raw_pointer(back)->~input_value_type();
141 <typename I, // I models InputIterator
142 typename F> // F models ForwardIterator
143 F uninitialized_move(I f, I l, F r,
144 typename ::boost::move_detail::disable_if<has_move_emulation_enabled<typename boost::movelib::iterator_traits<I>::value_type> >::type* = 0)
146 return std::uninitialized_copy(f, l, r);
152 } //namespace boost {
154 #include <boost/move/detail/config_end.hpp>
156 #endif //#ifndef BOOST_MOVE_ALGO_MOVE_HPP