1//////////////////////////////////////////////////////////////////////////////
2//
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)
7//
8// See http://www.boost.org/libs/move for documentation.
9//
10//////////////////////////////////////////////////////////////////////////////
11
12//! \file
13
14#ifndef BOOST_MOVE_ALGO_MOVE_HPP
15#define BOOST_MOVE_ALGO_MOVE_HPP
16
17#ifndef BOOST_CONFIG_HPP
18# include <boost/config.hpp>
19#endif
20#
21#if defined(BOOST_HAS_PRAGMA_ONCE)
22# pragma once
23#endif
24
25#include <boost/move/detail/config_begin.hpp>
26
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>
31
32namespace boost {
33
34//////////////////////////////////////////////////////////////////////////////
35//
36// move
37//
38//////////////////////////////////////////////////////////////////////////////
39
40#if !defined(BOOST_MOVE_USE_STANDARD_LIBRARY_MOVE)
41
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)).
45 //!
46 //! <b>Effects</b>: result + (last - first).
47 //!
48 //! <b>Requires</b>: result shall not be in the range [first,last).
49 //!
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)
54 {
55 while (f != l) {
56 *result = ::boost::move(*f);
57 ++f; ++result;
58 }
59 return result;
60 }
61
62 //////////////////////////////////////////////////////////////////////////////
63 //
64 // move_backward
65 //
66 //////////////////////////////////////////////////////////////////////////////
67
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)).
72 //!
73 //! <b>Requires</b>: result shall not be in the range [first,last).
74 //!
75 //! <b>Returns</b>: result - (last - first).
76 //!
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)
81 {
82 while (f != l) {
83 --l; --result;
84 *result = ::boost::move(*l);
85 }
86 return result;
87 }
88
89#else
90
91 using ::std::move_backward;
92
93#endif //!defined(BOOST_MOVE_USE_STANDARD_LIBRARY_MOVE)
94
95//////////////////////////////////////////////////////////////////////////////
96//
97// uninitialized_move
98//
99//////////////////////////////////////////////////////////////////////////////
100
101//! <b>Effects</b>:
102//! \code
103//! for (; first != last; ++result, ++first)
104//! new (static_cast<void*>(&*result))
105//! typename iterator_traits<ForwardIterator>::value_type(boost::move(*first));
106//! \endcode
107//!
108//! <b>Returns</b>: result
109template
110 <typename I, // I models InputIterator
111 typename F> // F models ForwardIterator
112F uninitialized_move(I f, I l, F r
113 /// @cond
114// ,typename ::boost::move_detail::enable_if<has_move_emulation_enabled<typename boost::movelib::iterator_traits<I>::value_type> >::type* = 0
115 /// @endcond
116 )
117{
118 typedef typename boost::movelib::iterator_traits<I>::value_type input_value_type;
119
120 F back = r;
121 BOOST_TRY{
122 while (f != l) {
123 void * const addr = static_cast<void*>(::boost::move_detail::addressof(*r));
124 ::new(addr) input_value_type(::boost::move(*f));
125 ++f; ++r;
126 }
127 }
128 BOOST_CATCH(...){
129 for (; back != r; ++back){
130 boost::movelib::iterator_to_raw_pointer(back)->~input_value_type();
131 }
132 BOOST_RETHROW;
133 }
134 BOOST_CATCH_END
135 return r;
136}
137
138/// @cond
139/*
140template
141 <typename I, // I models InputIterator
142 typename F> // F models ForwardIterator
143F 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)
145{
146 return std::uninitialized_copy(f, l, r);
147}
148*/
149
150/// @endcond
151
152} //namespace boost {
153
154#include <boost/move/detail/config_end.hpp>
155
156#endif //#ifndef BOOST_MOVE_ALGO_MOVE_HPP
157

source code of include/boost/move/algo/move.hpp