1 //////////////////////////////////////////////////////////////////////////////
3 // (C) Copyright Ion Gaztanaga 2012-2012.
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_ALGORITHM_HPP
15 #define BOOST_MOVE_ALGORITHM_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/iterator.hpp>
29 #include <boost/move/algo/move.hpp>
30 #include <boost/core/no_exceptions_support.hpp>
32 #include <algorithm> //copy, copy_backward
33 #include <memory> //uninitialized_copy
37 //////////////////////////////////////////////////////////////////////////////
39 // uninitialized_copy_or_move
41 //////////////////////////////////////////////////////////////////////////////
43 namespace move_detail {
46 <typename I, // I models InputIterator
47 typename F> // F models ForwardIterator
48 inline F uninitialized_move_move_iterator(I f, I l, F r
49 // ,typename ::boost::move_detail::enable_if< has_move_emulation_enabled<typename I::value_type> >::type* = 0
52 return ::boost::uninitialized_move(f, l, r);
56 <typename I, // I models InputIterator
57 typename F> // F models ForwardIterator
58 F uninitialized_move_move_iterator(I f, I l, F r,
59 typename ::boost::move_detail::disable_if< has_move_emulation_enabled<typename I::value_type> >::type* = 0)
61 return std::uninitialized_copy(f.base(), l.base(), r);
64 } //namespace move_detail {
67 <typename I, // I models InputIterator
68 typename F> // F models ForwardIterator
69 inline F uninitialized_copy_or_move(I f, I l, F r,
70 typename ::boost::move_detail::enable_if< move_detail::is_move_iterator<I> >::type* = 0)
72 return ::boost::move_detail::uninitialized_move_move_iterator(f, l, r);
75 //////////////////////////////////////////////////////////////////////////////
79 //////////////////////////////////////////////////////////////////////////////
81 namespace move_detail {
84 <typename I, // I models InputIterator
85 typename F> // F models ForwardIterator
86 inline F move_move_iterator(I f, I l, F r
87 // ,typename ::boost::move_detail::enable_if< has_move_emulation_enabled<typename I::value_type> >::type* = 0
90 return ::boost::move(f, l, r);
94 <typename I, // I models InputIterator
95 typename F> // F models ForwardIterator
96 F move_move_iterator(I f, I l, F r,
97 typename ::boost::move_detail::disable_if< has_move_emulation_enabled<typename I::value_type> >::type* = 0)
99 return std::copy(f.base(), l.base(), r);
103 } //namespace move_detail {
106 <typename I, // I models InputIterator
107 typename F> // F models ForwardIterator
108 inline F copy_or_move(I f, I l, F r,
109 typename ::boost::move_detail::enable_if< move_detail::is_move_iterator<I> >::type* = 0)
111 return ::boost::move_detail::move_move_iterator(f, l, r);
118 //! for (; first != last; ++result, ++first)
119 //! new (static_cast<void*>(&*result))
120 //! typename iterator_traits<ForwardIterator>::value_type(*first);
123 //! <b>Returns</b>: result
125 //! <b>Note</b>: This function is provided because
126 //! <i>std::uninitialized_copy</i> from some STL implementations
127 //! is not compatible with <i>move_iterator</i>
129 <typename I, // I models InputIterator
130 typename F> // F models ForwardIterator
131 inline F uninitialized_copy_or_move(I f, I l, F r
133 ,typename ::boost::move_detail::disable_if< move_detail::is_move_iterator<I> >::type* = 0
137 return std::uninitialized_copy(f, l, r);
142 //! for (; first != last; ++result, ++first)
143 //! *result = *first;
146 //! <b>Returns</b>: result
148 //! <b>Note</b>: This function is provided because
149 //! <i>std::uninitialized_copy</i> from some STL implementations
150 //! is not compatible with <i>move_iterator</i>
152 <typename I, // I models InputIterator
153 typename F> // F models ForwardIterator
154 inline F copy_or_move(I f, I l, F r
156 ,typename ::boost::move_detail::disable_if< move_detail::is_move_iterator<I> >::type* = 0
160 return std::copy(f, l, r);
163 } //namespace boost {
165 #include <boost/move/detail/config_end.hpp>
167 #endif //#ifndef BOOST_MOVE_ALGORITHM_HPP