Horizon
Loading...
Searching...
No Matches
move.hpp
Go to the documentation of this file.
1
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
14#ifndef RANGES_V3_VIEW_MOVE_HPP
15#define RANGES_V3_VIEW_MOVE_HPP
16
17#include <type_traits>
18#include <utility>
19
21
26#include <range/v3/utility/static_const.hpp>
28#include <range/v3/view/all.hpp>
30
31#include <range/v3/detail/prologue.hpp>
32
33namespace ranges
34{
37 template<typename Rng>
38 struct move_view : view_adaptor<move_view<Rng>, Rng>
39 {
40 private:
41 friend range_access;
42 template<bool Const>
43 struct adaptor : adaptor_base
44 {
45 adaptor() = default;
46 template(bool Other)(
47 requires Const AND CPP_NOT(Other)) //
48 constexpr adaptor(adaptor<Other>)
49 {}
50 using CRng = meta::const_if_c<Const, Rng>;
51 using value_type = range_value_t<Rng>;
52 range_rvalue_reference_t<CRng> read(iterator_t<CRng> const & it) const
53 {
54 return ranges::iter_move(it);
55 }
56 range_rvalue_reference_t<CRng> iter_move(iterator_t<CRng> const & it) const
57 {
58 return ranges::iter_move(it);
59 }
60 };
61 adaptor<simple_view<Rng>()> begin_adaptor()
62 {
63 return {};
64 }
65 adaptor<simple_view<Rng>()> end_adaptor()
66 {
67 return {};
68 }
69 CPP_member
70 auto begin_adaptor() const //
71 -> CPP_ret(adaptor<true>)(
73 {
74 return {};
75 }
76 CPP_member
77 auto end_adaptor() const //
78 -> CPP_ret(adaptor<true>)(
80 {
81 return {};
82 }
83
84 public:
85 move_view() = default;
86 explicit move_view(Rng rng)
87 : move_view::view_adaptor{std::move(rng)}
88 {}
89 CPP_auto_member
90 auto CPP_fun(size)()(const //
92 {
93 return ranges::size(this->base());
94 }
95 CPP_auto_member
96 auto CPP_fun(size)()(
97 requires sized_range<Rng>)
98 {
99 return ranges::size(this->base());
100 }
101 };
102
103 template<typename Rng>
104 RANGES_INLINE_VAR constexpr bool enable_borrowed_range<move_view<Rng>> =
105 enable_borrowed_range<Rng>;
106
107#if RANGES_CXX_DEDUCTION_GUIDES >= RANGES_CXX_DEDUCTION_GUIDES_17
108 template<typename Rng>
109 move_view(Rng &&) //
111#endif
112
113 namespace views
114 {
115 struct move_fn
116 {
117 template(typename Rng)(
119 move_view<all_t<Rng>> operator()(Rng && rng) const
120 {
121 return move_view<all_t<Rng>>{all(static_cast<Rng &&>(rng))};
122 }
123 };
124
127 RANGES_INLINE_VARIABLE(view_closure<move_fn>, move)
128 } // namespace views
130} // namespace ranges
131
132#include <range/v3/detail/epilogue.hpp>
133#include <range/v3/detail/satisfy_boost_range.hpp>
134RANGES_SATISFY_BOOST_RANGE(::ranges::move_view)
135
136#endif
The input_range concept.
The sized_range concept.
The viewable_range concept.
decltype(begin(declval(Rng &))) iterator_t
Definition access.hpp:698
Definition adaptor.hpp:110
Definition move.hpp:39
Definition adaptor.hpp:475
Definition move.hpp:116
Definition view.hpp:178