Horizon
rotate_copy.hpp
Go to the documentation of this file.
1 // 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 
21 #include <range/v3/algorithm/result_types.hpp>
29 #include <range/v3/utility/static_const.hpp>
30 
31 #include <range/v3/detail/prologue.hpp>
32 
33 namespace ranges
34 {
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 
43  template(typename I, typename S, typename O, typename P = identity)(
44  requires forward_iterator<I> AND sentinel_for<S, I> AND
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 
55  template(typename Rng, typename O, typename P = identity)(
56  requires range<Rng> AND weakly_incrementable<O> AND
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
72 } // namespace ranges
73 
74 #include <range/v3/detail/epilogue.hpp>
75 
76 #endif
template(typename Rng, typename O, typename P=identity)(requires range< Rng > AND weakly_incrementable< O > AND indirectly_copyable< iterator_t< Rng >
This is an overloaded member function, provided for convenience. It differs from the above function o...
CPP_concept sentinel_for
\concept sentinel_for
Definition: concepts.hpp:306
CPP_concept forward_iterator
\concept forward_iterator
Definition: concepts.hpp:370
CPP_concept indirectly_copyable
\concept indirectly_copyable
Definition: concepts.hpp:782
CPP_concept weakly_incrementable
\concept weakly_incrementable
Definition: concepts.hpp:268
decltype(begin(declval(Rng &))) iterator_t
Definition: access.hpp:698
front< Pair > first
Retrieve the first element of the pair Pair.
Definition: meta.hpp:2251
Definition: identity.hpp:25