1//////////////////////////////////////////////////////////////////////////////
2//
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)
7//
8// See http://www.boost.org/libs/move for documentation.
9//
10//////////////////////////////////////////////////////////////////////////////
11
12//! \file
13
14#ifndef BOOST_MOVE_ALGORITHM_HPP
15#define BOOST_MOVE_ALGORITHM_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/iterator.hpp>
29#include <boost/move/algo/move.hpp>
30
31#include <algorithm> //copy, copy_backward
32#include <memory> //uninitialized_copy
33
34namespace boost {
35
36//////////////////////////////////////////////////////////////////////////////
37//
38// uninitialized_copy_or_move
39//
40//////////////////////////////////////////////////////////////////////////////
41
42namespace move_detail {
43
44template
45<typename I, // I models InputIterator
46typename F> // F models ForwardIterator
47inline F uninitialized_move_move_iterator(I f, I l, F r
48// ,typename ::boost::move_detail::enable_if< has_move_emulation_enabled<typename I::value_type> >::type* = 0
49)
50{
51 return ::boost::uninitialized_move(f, l, r);
52}
53/*
54template
55<typename I, // I models InputIterator
56typename F> // F models ForwardIterator
57F uninitialized_move_move_iterator(I f, I l, F r,
58 typename ::boost::move_detail::disable_if< has_move_emulation_enabled<typename I::value_type> >::type* = 0)
59{
60 return std::uninitialized_copy(f.base(), l.base(), r);
61}
62*/
63} //namespace move_detail {
64
65template
66<typename I, // I models InputIterator
67typename F> // F models ForwardIterator
68inline F uninitialized_copy_or_move(I f, I l, F r,
69 typename ::boost::move_detail::enable_if< move_detail::is_move_iterator<I> >::type* = 0)
70{
71 return ::boost::move_detail::uninitialized_move_move_iterator(f, l, r);
72}
73
74//////////////////////////////////////////////////////////////////////////////
75//
76// copy_or_move
77//
78//////////////////////////////////////////////////////////////////////////////
79
80namespace move_detail {
81
82template
83<typename I, // I models InputIterator
84typename F> // F models ForwardIterator
85inline F move_move_iterator(I f, I l, F r
86// ,typename ::boost::move_detail::enable_if< has_move_emulation_enabled<typename I::value_type> >::type* = 0
87)
88{
89 return ::boost::move(f, l, r);
90}
91/*
92template
93<typename I, // I models InputIterator
94typename F> // F models ForwardIterator
95F move_move_iterator(I f, I l, F r,
96 typename ::boost::move_detail::disable_if< has_move_emulation_enabled<typename I::value_type> >::type* = 0)
97{
98 return std::copy(f.base(), l.base(), r);
99}
100*/
101
102} //namespace move_detail {
103
104template
105<typename I, // I models InputIterator
106typename F> // F models ForwardIterator
107inline F copy_or_move(I f, I l, F r,
108 typename ::boost::move_detail::enable_if< move_detail::is_move_iterator<I> >::type* = 0)
109{
110 return ::boost::move_detail::move_move_iterator(f, l, r);
111}
112
113/// @endcond
114
115//! <b>Effects</b>:
116//! \code
117//! for (; first != last; ++result, ++first)
118//! new (static_cast<void*>(&*result))
119//! typename iterator_traits<ForwardIterator>::value_type(*first);
120//! \endcode
121//!
122//! <b>Returns</b>: result
123//!
124//! <b>Note</b>: This function is provided because
125//! <i>std::uninitialized_copy</i> from some STL implementations
126//! is not compatible with <i>move_iterator</i>
127template
128<typename I, // I models InputIterator
129typename F> // F models ForwardIterator
130inline F uninitialized_copy_or_move(I f, I l, F r
131 /// @cond
132 ,typename ::boost::move_detail::disable_if< move_detail::is_move_iterator<I> >::type* = 0
133 /// @endcond
134 )
135{
136 return std::uninitialized_copy(f, l, r);
137}
138
139//! <b>Effects</b>:
140//! \code
141//! for (; first != last; ++result, ++first)
142//! *result = *first;
143//! \endcode
144//!
145//! <b>Returns</b>: result
146//!
147//! <b>Note</b>: This function is provided because
148//! <i>std::uninitialized_copy</i> from some STL implementations
149//! is not compatible with <i>move_iterator</i>
150template
151<typename I, // I models InputIterator
152typename F> // F models ForwardIterator
153inline F copy_or_move(I f, I l, F r
154 /// @cond
155 ,typename ::boost::move_detail::disable_if< move_detail::is_move_iterator<I> >::type* = 0
156 /// @endcond
157 )
158{
159 return std::copy(f, l, r);
160}
161
162} //namespace boost {
163
164#include <boost/move/detail/config_end.hpp>
165
166#endif //#ifndef BOOST_MOVE_ALGORITHM_HPP
167