Horizon
move.hpp
Go to the documentation of this file.
1 // Range v3 library
3 //
4 // Copyright Eric Niebler 2014-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_MOVE_HPP
14 #define RANGES_V3_ALGORITHM_MOVE_HPP
15 
16 #include <utility>
17 
18 #include <range/v3/range_fwd.hpp>
19 
20 #include <range/v3/algorithm/result_types.hpp>
28 #include <range/v3/utility/static_const.hpp>
29 
30 #include <range/v3/detail/prologue.hpp>
31 
32 namespace ranges
33 {
36  template<typename I, typename O>
37  using move_result = detail::in_out_result<I, O>;
38 
39  RANGES_HIDDEN_DETAIL(namespace _move CPP_PP_LBRACE())
40  RANGES_FUNC_BEGIN(move)
41 
43  template(typename I, typename S, typename O)(
44  requires input_iterator<I> AND sentinel_for<S, I> AND
46  constexpr move_result<I, O> RANGES_FUNC(move)(I first, S last, O out) //
47  {
48  for(; first != last; ++first, ++out)
49  *out = iter_move(first);
50  return {first, out};
51  }
52 
54  template(typename Rng, typename O)(
55  requires input_range<Rng> AND weakly_incrementable<O> AND
56  indirectly_movable<iterator_t<Rng>, O>)
57  constexpr move_result<borrowed_iterator_t<Rng>, O> //
58  RANGES_FUNC(move)(Rng && rng, O out) //
59  {
60  return (*this)(begin(rng), end(rng), std::move(out));
61  }
62 
63  RANGES_FUNC_END(move)
64  RANGES_HIDDEN_DETAIL(CPP_PP_RBRACE())
65 
66 #ifndef RANGES_DOXYGEN_INVOKED
67  struct RANGES_EMPTY_BASES move_fn
68  : aux::move_fn
69  , _move::move_fn
70  {
71  using aux::move_fn::operator();
72  using _move::move_fn::operator();
73  };
74 
76 #endif
77 
78  namespace cpp20
79  {
80  using ranges::move_result;
81  using ranges::RANGES_HIDDEN_DETAIL(_move::) move;
82  } // namespace cpp20
84 } // namespace ranges
85 
86 #include <range/v3/detail/epilogue.hpp>
87 
88 #endif
template(typename ActionFn, typename Rng)(concept(invocable_action_closure_)(ActionFn
\concept invocable_action_closure_
CPP_concept sentinel_for
\concept sentinel_for
Definition: concepts.hpp:306
CPP_concept input_iterator
\concept input_iterator
Definition: concepts.hpp:362
CPP_concept indirectly_movable
\concept indirectly_movable
Definition: concepts.hpp:752
CPP_concept weakly_incrementable
\concept weakly_incrementable
Definition: concepts.hpp:268
RANGES_INLINE_VARIABLE(detail::to_container_fn< detail::from_range< std::vector >>, to_vector) template< template< typename... > class ContT > auto to(RANGES_HIDDEN_DETAIL(detail
For initializing a container of the specified type with the elements of an Range.
Definition: conversion.hpp:399
front< Pair > first
Retrieve the first element of the pair Pair.
Definition: meta.hpp:2251
Definition: move.hpp:33
Definition: move.hpp:70