14 #ifndef RANGES_V3_ITERATOR_RANGE_HPP
15 #define RANGES_V3_ITERATOR_RANGE_HPP
17 #include <type_traits>
29 #include <range/v3/utility/static_const.hpp>
33 "This header is deprecated. Please switch to subrange in "
34 "<range/v3/view/subrange.hpp>.")
36 #include <range/v3/detail/prologue.hpp>
43 template<
typename I,
typename S>
44 RANGES_INLINE_VAR constexpr
bool enable_borrowed_range<iterator_range<I, S>> =
true;
46 template<
typename I,
typename S>
47 RANGES_INLINE_VAR constexpr
bool enable_borrowed_range<sized_iterator_range<I, S>> =
50 template<
typename I,
typename S >
51 struct RANGES_EMPTY_BASES iterator_range
52 : view_interface<iterator_range<I, S>,
53 same_as<S, unreachable_sentinel_t> ? infinite : unknown>
54 , compressed_pair<I, S>
57 template<
typename,
typename>
58 friend struct iterator_range;
59 template<
typename,
typename>
60 friend struct sized_iterator_range;
61 compressed_pair<I, S> & base() noexcept
65 compressed_pair<I, S>
const & base() const noexcept
76 using const_iterator = I;
79 constexpr I & begin() &
83 constexpr I
const & begin() const &
92 constexpr S
const & end() const &
97 iterator_range() =
default;
98 constexpr iterator_range(I
first, S last)
99 : compressed_pair<I, S>{detail::move(
first), detail::move(last)}
101 template(
typename X,
typename Y)(
102 requires constructible_from<I, X> AND constructible_from<S, Y>)
103 constexpr iterator_range(iterator_range<X, Y> rng)
104 : compressed_pair<I, S>{detail::move(rng.begin()), detail::move(rng.end())}
106 template(
typename X,
typename Y)(
107 requires constructible_from<I, X> AND constructible_from<S, Y>)
108 constexpr
explicit iterator_range(std::pair<X, Y> rng)
109 : compressed_pair<I, S>{detail::move(rng.first), detail::move(rng.second)}
111 template(
typename X,
typename Y)(
112 requires assignable_from<I &, X> AND assignable_from<S &, Y>)
113 iterator_range & operator=(iterator_range<X, Y> rng)
115 base().first() = std::move(rng.base()).first();
116 base().second() = std::move(rng.base()).second();
119 template(
typename X,
typename Y)(
120 requires convertible_to<I, X> AND convertible_to<S, Y>)
121 constexpr
operator std::pair<X, Y>()
const
123 return {base().first(), base().second()};
125 constexpr
bool empty()
const
127 return base().first() == base().second();
137 template<
typename I,
typename S >
138 struct sized_iterator_range
139 : view_interface<sized_iterator_range<I, S>, finite>
141 using size_type = detail::iter_size_t<I>;
144 #ifndef RANGES_DOXYGEN_INVOKED
145 using const_iterator = I;
149 template<
typename X,
typename Y>
150 friend struct sized_iterator_range;
151 iterator_range<I, S> rng_;
155 sized_iterator_range() =
default;
156 RANGES_NDEBUG_CONSTEXPR sized_iterator_range(I
first, S last, size_type
size)
157 : rng_{detail::move(
first), detail::move(last)}
161 RANGES_ASSERT(!(
bool)forward_iterator<I> ||
162 static_cast<size_type
>(ranges::distance(rng_)) == size_);
165 template(
typename X,
typename Y)(
166 requires constructible_from<I, X> AND constructible_from<S, Y>)
167 RANGES_NDEBUG_CONSTEXPR sized_iterator_range(std::pair<X, Y> rng, size_type
size)
168 : sized_iterator_range{detail::move(rng).
first, detail::move(rng).
second,
size}
170 template(
typename X,
typename Y)(
171 requires constructible_from<I, X> AND constructible_from<S, Y>)
172 RANGES_NDEBUG_CONSTEXPR sized_iterator_range(iterator_range<X, Y> rng,
174 : sized_iterator_range{detail::move(rng).
first(),
178 template(
typename X,
typename Y)(
179 requires constructible_from<I, X> AND constructible_from<S, Y>)
180 RANGES_NDEBUG_CONSTEXPR sized_iterator_range(sized_iterator_range<X, Y> rng)
181 : sized_iterator_range{detail::move(rng).rng_.
first(),
182 detail::move(rng).rng_.
second,
185 template(
typename X,
typename Y)(
186 requires assignable_from<I &, X> AND assignable_from<S &, Y>)
187 sized_iterator_range & operator=(sized_iterator_range<X, Y> rng)
189 rng_ = detail::move(rng).rng_;
201 size_type
size() const noexcept
205 template(
typename X,
typename Y)(
206 requires convertible_to<I, X> AND convertible_to<S, Y>)
207 constexpr
operator std::pair<X, Y>()
const
211 template(
typename X,
typename Y)(
212 requires convertible_to<I, X> AND convertible_to<S, Y>)
213 constexpr
operator iterator_range<X, Y>()
const
217 constexpr
operator iterator_range<I, S>
const &()
const & noexcept
225 friend constexpr
auto CPP_auto_fun(get)(sized_iterator_range
const &p)
228 return ranges::get<N>(p.*&sized_iterator_range::rng_)
234 friend constexpr size_type get(sized_iterator_range
const & p) noexcept
240 struct make_iterator_range_fn
243 template(
typename I,
typename S)(
244 requires sentinel_for<S, I>)
245 constexpr iterator_range<I, S> operator()(I
first, S last)
const
247 return {detail::move(
first), detail::move(last)};
251 template(
typename I,
typename S)(
252 requires sentinel_for<S, I>)
253 constexpr sized_iterator_range<I, S>
254 operator()(I
first, S last, detail::iter_size_t<I> sz)
const
256 return {detail::move(
first), detail::move(last), sz};
270 RANGES_DIAGNOSTIC_PUSH
271 RANGES_DIAGNOSTIC_IGNORE_MISMATCHED_TAGS
276 template<
typename I,
typename S>
277 struct tuple_size<::ranges::iterator_range<I, S>> : std::integral_constant<size_t, 2>
280 template<
typename I,
typename S>
281 struct tuple_element<0, ::ranges::iterator_range<I, S>>
286 template<
typename I,
typename S>
287 struct tuple_element<1, ::ranges::iterator_range<I, S>>
292 template<
typename I,
typename S>
294 : std::integral_constant<size_t, 3>
297 template<
typename I,
typename S>
303 template<
typename I,
typename S>
309 template<
typename I,
typename S>
312 using type = typename ::ranges::sized_iterator_range<I, S>::size_type;
317 RANGES_DIAGNOSTIC_POP
319 #include <range/v3/detail/epilogue.hpp>
CPP_concept type
\concept type
Definition: concepts.hpp:838
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
RANGES_DEPRECATED_HEADER("This header is deprecated and will be removed from a future version of range-v3.") namespace ranges
Definition: nullptr_v.hpp:17
std::integral_constant< std::size_t, N > size_t
An integral constant wrapper for std::size_t.
Definition: meta.hpp:163
front< Pair > first
Retrieve the first element of the pair Pair.
Definition: meta.hpp:2251
meta::size_t< L::size()> size
An integral constant wrapper that is the size of the meta::list L.
Definition: meta.hpp:1696
front< pop_front< Pair > > second
Retrieve the first element of the pair Pair.
Definition: meta.hpp:2256
bool_< 0==size< L >::type::value > empty
An Boolean integral constant wrapper around true if L is an empty type list; false,...
Definition: meta.hpp:2231
Definition: range_fwd.hpp:591