std::ranges::views::to_input, std::ranges::to_input_view
| Defined in header <ranges>
|
||
| template< ranges::input_range V > requires ranges::view<V> |
(1) | (since C++26) |
| namespace views { inline constexpr /* unspecified */ to_input = /* unspecified */; |
(2) | (since C++26) |
| Call signature |
||
| template< ranges::viewable_range R > requires /* see below */ |
(since C++26) | |
view as an input_range-only and not a common_range.- views::all(e), if it is a well-formed expression and all of the conditions below are true:
-
Tmodelsinput_range, -
Tdoes not satisfycommon_range, and -
Tdoes not satisfyforward_range.
-
- to_input_view{e} otherwise.
Consequently, to_input_view never models range concepts that are stronger than input_range. In particular, it does not model all of these:
Additionally, to_input_view does not model common_range. However, it does model borrowed_range, constant_range, and sized_range when the underlying view V models respective concepts.
Contents |
[edit] Data members
| Member | Description |
V base_ (private)
|
the underlying view (exposition-only member object*) |
[edit] Member functions
constructs a to_input_view (public member function) | |
| returns a copy of the underlying (adapted) view (public member function) | |
| returns an iterator to the beginning (public member function) | |
| returns an iterator or a sentinel to the end (public member function) | |
returns the number of elements. Provided only if the underlying (adapted) range satisfies sized_range. (public member function) | |
Inherited from std::ranges::view_interface | |
returns whether the derived view is empty, provided only if it satisfies sized_range or forward_range (public member function of std::ranges::view_interface<D>)
| |
| (C++23) |
returns a constant iterator to the beginning of the range (public member function of std::ranges::view_interface<D>)
|
| (C++23) |
returns a sentinel for the constant iterator of the range (public member function of std::ranges::view_interface<D>)
|
| returns whether the derived view is not empty, provided only if ranges::empty is applicable to it (public member function of std::ranges::view_interface<D>)
| |
gets the address of derived view's data, provided only if its iterator type satisfies contiguous_iterator (public member function of std::ranges::view_interface<D>)
| |
returns the first element in the derived view, provided if it satisfies forward_range (public member function of std::ranges::view_interface<D>)
| |
returns the last element in the derived view, provided only if it satisfies bidirectional_range and common_range (public member function of std::ranges::view_interface<D>)
| |
returns the nth element in the derived view, provided only if it satisfies random_access_range (public member function of std::ranges::view_interface<D>)
| |
std::ranges::to_input_view::to_input_view
| to_input_view() requires std::default_initializable<V> = default; |
(1) | (since C++26) |
| constexpr explicit to_input_view( V base ); |
(2) | (since C++26) |
base_ via its default member initializer (= V()).base_ with std::move(base).Parameters
| base | - | a view |
std::ranges::to_input_view::base
| constexpr V base() const& requires std::copy_constructible<V>; |
(1) | (since C++26) |
| constexpr V base() &&; |
(2) | (since C++26) |
std::ranges::to_input_view::begin
| constexpr auto begin() requires (!__simple_view<V>); |
(1) | (since C++26) |
| constexpr auto begin() const requires ranges::range<const V>; |
(2) | (since C++26) |
std::ranges::to_input_view::end
| constexpr auto end() requires (!__simple_view<V>); |
(1) | (since C++26) |
| constexpr auto end() const requires ranges::range<const V>; |
(2) | (since C++26) |
std::ranges::to_input_view::size
| constexpr auto size() requires ranges::sized_range<V>; |
(1) | (since C++26) |
| constexpr auto size() const requires ranges::sized_range<const V>; |
(2) | (since C++26) |
[edit] Deduction guides
| template< class R > to_input_view( R&& ) -> to_input_view<views::all_t<R>>; |
(since C++26) | |
[edit] Nested classes
| the iterator type (exposition-only member class template*) |
[edit] Helper templates
| template< class T > constexpr bool enable_borrowed_range<std::ranges::to_input_view<T>> = |
(since C++26) | |
This specialization of std::ranges::enable_borrowed_range makes to_input_view satisfy borrowed_range when the underlying view satisfies it.
[edit] Notes
to_input_view can be useful to avoid the overhead necessary to provide support for the operations needed for greater iterator strength.
| Feature-test macro | Value | Std | Feature |
|---|---|---|---|
__cpp_lib_ranges_to_input |
202502L |
(C++26) | std::ranges::to_input_view
|
[edit] Example
| This section is incomplete Reason: no example |
[edit] See also
| (C++20) |
specifies a range whose iterator type satisfies input_iterator (concept) |
converts a view into a common_range(class template) (range adaptor object) |