| 1 |
/// \file |
| 2 |
// Range v3 library |
| 3 |
// |
| 4 |
// Copyright Eric Niebler 2013-present |
| 5 |
// |
| 6 |
// Use, modification and distribution is subject to the |
| 7 |
// Boost Software License, Version 1.0. (See accompanying |
| 8 |
// file LICENSE_1_0.txt or copy at |
| 9 |
// http://www.boost.org/LICENSE_1_0.txt) |
| 10 |
// |
| 11 |
// Project home: https://github.com/ericniebler/range-v3 |
| 12 |
// |
| 13 |
#ifndef RANGES_V3_ALGORITHM_ROTATE_COPY_HPP |
| 14 |
#define RANGES_V3_ALGORITHM_ROTATE_COPY_HPP |
| 15 |
|
| 16 |
#include <functional> |
| 17 |
|
| 18 |
#include <range/v3/range_fwd.hpp> |
| 19 |
|
| 20 |
#include <range/v3/algorithm/copy.hpp> |
| 21 |
#include <range/v3/algorithm/result_types.hpp> |
| 22 |
#include <range/v3/functional/identity.hpp> |
| 23 |
#include <range/v3/iterator/concepts.hpp> |
| 24 |
#include <range/v3/iterator/traits.hpp> |
| 25 |
#include <range/v3/range/access.hpp> |
| 26 |
#include <range/v3/range/concepts.hpp> |
| 27 |
#include <range/v3/range/dangling.hpp> |
| 28 |
#include <range/v3/range/traits.hpp> |
| 29 |
#include <range/v3/utility/static_const.hpp> |
| 30 |
|
| 31 |
#include <range/v3/detail/prologue.hpp> |
| 32 |
|
| 33 |
namespace ranges |
| 34 |
{ |
| 35 |
/// \addtogroup group-algorithms |
| 36 |
/// @{ |
| 37 |
template<typename I, typename O> |
| 38 |
using rotate_copy_result = detail::in_out_result<I, O>; |
| 39 |
|
| 40 |
RANGES_FUNC_BEGIN(rotate_copy) |
| 41 |
|
| 42 |
/// \brief function template \c rotate_copy |
| 43 |
template(typename I, typename S, typename O, typename P = identity)( |
| 44 |
requires forward_iterator<I> AND sentinel_for<S, I> AND |
| 45 |
weakly_incrementable<O> AND indirectly_copyable<I, O>) |
| 46 |
constexpr rotate_copy_result<I, O> // |
| 47 |
RANGES_FUNC(rotate_copy)(I first, I middle, S last, O out) // |
| 48 |
{ |
| 49 |
auto res = ranges::copy(middle, std::move(last), std::move(out)); |
| 50 |
return {std::move(res.in), |
| 51 |
ranges::copy(std::move(first), middle, std::move(res.out)).out}; |
| 52 |
} |
| 53 |
|
| 54 |
/// \overload |
| 55 |
template(typename Rng, typename O, typename P = identity)( |
| 56 |
requires range<Rng> AND weakly_incrementable<O> AND |
| 57 |
indirectly_copyable<iterator_t<Rng>, O>) |
| 58 |
constexpr rotate_copy_result<borrowed_iterator_t<Rng>, O> // |
| 59 |
RANGES_FUNC(rotate_copy)(Rng && rng, iterator_t<Rng> middle, O out) // |
| 60 |
{ |
| 61 |
return (*this)(begin(rng), std::move(middle), end(rng), std::move(out)); |
| 62 |
} |
| 63 |
|
| 64 |
RANGES_FUNC_END(rotate_copy) |
| 65 |
|
| 66 |
namespace cpp20 |
| 67 |
{ |
| 68 |
using ranges::rotate_copy; |
| 69 |
using ranges::rotate_copy_result; |
| 70 |
} // namespace cpp20 |
| 71 |
/// @} |
| 72 |
} // namespace ranges |
| 73 |
|
| 74 |
#include <range/v3/detail/epilogue.hpp> |
| 75 |
|
| 76 |
#endif |