13#ifndef RANGES_V3_VIEW_COMMON_HPP
14#define RANGES_V3_VIEW_COMMON_HPP
26#include <range/v3/utility/static_const.hpp>
31#include <range/v3/detail/prologue.hpp>
45 CPP_concept random_access_and_sized_range =
46 random_access_range<R> && sized_range<R>;
50 using common_view_iterator_t =
51 meta::if_c<random_access_and_sized_range<R>, iterator_t<R>,
52 common_iterator_t<iterator_t<R>, sentinel_t<R>>>;
54 template<
typename Rng>
55 struct is_common_range :
meta::bool_<common_range<Rng>>
60 template<typename Rng, bool = detail::is_common_range<Rng>::value>
68 sentinel_t<Rng> end_(std::false_type)
70 return ranges::end(rng_);
74 return ranges::begin(rng_) + ranges::distance(rng_);
76 template(
bool Const =
true)(
77 requires Const AND
range<meta::const_if_c<Const, Rng>>)
78 sentinel_t<meta::const_if_c<Const, Rng>> end_(std::false_type)
const
80 return ranges::end(rng_);
82 template(
bool Const =
true)(
83 requires Const AND
range<meta::const_if_c<Const, Rng>>)
86 return ranges::begin(rng_) + ranges::distance(rng_);
92 : rng_(detail::move(rng))
99 detail::common_view_iterator_t<Rng> begin()
101 return detail::common_view_iterator_t<Rng>{ranges::begin(rng_)};
103 detail::common_view_iterator_t<Rng> end()
105 return detail::common_view_iterator_t<Rng>{
106 end_(
meta::bool_<detail::random_access_and_sized_range<Rng>>{})};
109 auto CPP_fun(size)()(
115 template(
bool Const =
true)(
116 requires range<meta::const_if_c<Const, Rng>>)
118 -> detail::common_view_iterator_t<meta::const_if_c<Const, Rng>>
120 return detail::common_view_iterator_t<meta::const_if_c<Const, Rng>>{
121 ranges::begin(rng_)};
123 template(
bool Const =
true)(
124 requires range<meta::const_if_c<Const, Rng>>)
126 -> detail::common_view_iterator_t<meta::const_if_c<Const, Rng>>
128 return detail::common_view_iterator_t<meta::const_if_c<Const, Rng>>{
129 end_(
meta::bool_<detail::random_access_and_sized_range<
130 meta::const_if_c<Const, Rng>>>{})};
133 auto CPP_fun(size)()(
const
140 template<
typename Rng,
bool B>
141 RANGES_INLINE_VAR
constexpr bool enable_borrowed_range<common_view<Rng, B>> =
142 enable_borrowed_range<Rng>;
144#if RANGES_CXX_DEDUCTION_GUIDES >= RANGES_CXX_DEDUCTION_GUIDES_17
145 template(
typename Rng)(
148 ->common_view<views::all_t<Rng>>;
151 template<
typename Rng>
162 template(
typename Rng)(
164 all_t<Rng> operator()(Rng && rng)
const
166 return all(
static_cast<Rng &&
>(rng));
169 template(
typename Rng)(
171 common_view<all_t<Rng>>
operator()(Rng && rng)
const
179 template(
typename Rng)(
194 template<
typename Rng>
195 using bounded_view RANGES_DEPRECATED(
196 "The name bounded_view is deprecated. "
206 "The name views::bounded is deprecated. "
207 "Please use views::common instead.")
208 RANGES_INLINE_VAR constexpr auto & bounded = common;
211 template<typename Rng>
212 using bounded_t RANGES_DEPRECATED("The name views::bounded_t
is deprecated.") =
213 decltype(common(std::declval<Rng>()));
224 template(
typename Rng)(
225 requires view_<Rng> && (!common_range<Rng>))
230#include <range/v3/detail/epilogue.hpp>
232#include <range/v3/detail/satisfy_boost_range.hpp>
The common_range concept.
The viewable_range concept.
decltype(begin(declval(Rng &))) iterator_t
Definition: access.hpp:698
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
std::integral_constant< bool, B > bool_
An integral constant wrapper for bool.
Definition: meta.hpp:168
meta::size_t< L::size()> size
An integral constant wrapper that is the size of the meta::list L.
Definition: meta.hpp:1696
_t< detail::is_< T, C > > is
is
Definition: meta.hpp:874
Definition: common.hpp:62
Definition: interface.hpp:129
Definition: common.hpp:178
Definition: common.hpp:161