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/detail/no_exceptions_support.hpp>
33 //////////////////////////////////////////////////////////////////////////////
37 //////////////////////////////////////////////////////////////////////////////
39 #if !defined(BOOST_MOVE_USE_STANDARD_LIBRARY_MOVE)
41 //! <b>Effects</b>: Moves elements in the range [first,last) into the range [result,result + (last -
42 //! first)) starting from first and proceeding to last. For each non-negative integer n < (last-first),
43 //! performs *(result + n) = ::boost::move (*(first + n)).
45 //! <b>Effects</b>: result + (last - first).
47 //! <b>Requires</b>: result shall not be in the range [first,last).
49 //! <b>Complexity</b>: Exactly last - first move assignments.
50 template <typename I, // I models InputIterator
51 typename O> // O models OutputIterator
52 O move(I f, I l, O result)
55 *result = ::boost::move(*f);
61 //////////////////////////////////////////////////////////////////////////////
65 //////////////////////////////////////////////////////////////////////////////
67 //! <b>Effects</b>: Moves elements in the range [first,last) into the range
68 //! [result - (last-first),result) starting from last - 1 and proceeding to
69 //! first. For each positive integer n <= (last - first),
70 //! performs *(result - n) = ::boost::move(*(last - n)).
72 //! <b>Requires</b>: result shall not be in the range [first,last).
74 //! <b>Returns</b>: result - (last - first).
76 //! <b>Complexity</b>: Exactly last - first assignments.
77 template <typename I, // I models BidirectionalIterator
78 typename O> // O models BidirectionalIterator
79 O move_backward(I f, I l, O result)
83 *result = ::boost::move(*l);
90 using ::std::move_backward;
92 #endif //!defined(BOOST_MOVE_USE_STANDARD_LIBRARY_MOVE)
94 //////////////////////////////////////////////////////////////////////////////
98 //////////////////////////////////////////////////////////////////////////////
102 //! for (; first != last; ++result, ++first)
103 //! new (static_cast<void*>(&*result))
104 //! typename iterator_traits<ForwardIterator>::value_type(boost::move(*first));
107 //! <b>Returns</b>: result
109 <typename I, // I models InputIterator
110 typename F> // F models ForwardIterator
111 F uninitialized_move(I f, I l, F r
113 // ,typename ::boost::move_detail::enable_if<has_move_emulation_enabled<typename boost::movelib::iterator_traits<I>::value_type> >::type* = 0
117 typedef typename boost::movelib::iterator_traits<I>::value_type input_value_type;
122 void * const addr = static_cast<void*>(::boost::move_detail::addressof(*r));
123 ::new(addr) input_value_type(::boost::move(*f));
128 for (; back != r; ++back){
129 back->~input_value_type();
140 <typename I, // I models InputIterator
141 typename F> // F models ForwardIterator
142 F uninitialized_move(I f, I l, F r,
143 typename ::boost::move_detail::disable_if<has_move_emulation_enabled<typename boost::movelib::iterator_traits<I>::value_type> >::type* = 0)
145 return std::uninitialized_copy(f, l, r);
151 } //namespace boost {
153 #include <boost/move/detail/config_end.hpp>
155 #endif //#ifndef BOOST_MOVE_ALGO_MOVE_HPP