Range-v3
Range algorithms, views, and actions for the Standard Library
 
Loading...
Searching...
No Matches
ranges::views::cache1_fn Struct Reference
+ Inheritance diagram for ranges::views::cache1_fn:

Public Member Functions

template<typename Rng >
requires viewable_range<Rng> && input_range<Rng> && constructible_from<range_value_t<Rng>, range_reference_t<Rng>>
constexpr cache1_view< all_t< Rng > > operator() (Rng &&rng) const
 Caches the most recent element within the view so that dereferencing the view's iterator multiple times doesn't incur any recomputation. This can be useful in adaptor pipelines that include combinations of view::filter and view::transform, for instance.
 

Related Symbols

(Note that these are not member symbols.)

constexpr view_closure< cache1_fncache1 {}
 

Member Function Documentation

◆ operator()()

template<typename Rng >
requires viewable_range<Rng> && input_range<Rng> && constructible_from<range_value_t<Rng>, range_reference_t<Rng>>
cache1_view< all_t< Rng > > ranges::views::cache1_fn::operator() ( Rng && rng) const
constexpr

Caches the most recent element within the view so that dereferencing the view's iterator multiple times doesn't incur any recomputation. This can be useful in adaptor pipelines that include combinations of view::filter and view::transform, for instance.

Note
views::cache1 is always single-pass.