24 Ranges library [ranges]

24.7 Range adaptors [range.adaptors]

24.7.22 Adjacent transform view [range.adjacent.transform]

24.7.22.2 Class template adjacent_­transform_­view [range.adjacent.transform.view]

namespace std::ranges { template<forward_­range V, copy_­constructible F, size_t N> requires view<V> && (N > 0) && is_object_v<F> && regular_­invocable<F&, REPEAT(range_reference_t<V>, N)...> && can-reference<invoke_result_t<F&, REPEAT(range_reference_t<V>, N)...>> class adjacent_transform_view : public view_interface<adjacent_transform_view<V, F, N>> { copyable-box<F> fun_; // exposition only adjacent_view<V, N> inner_; // exposition only using InnerView = adjacent_view<V, N>; // exposition only template<bool Const> using inner-iterator = iterator_t<maybe-const<Const, InnerView>>; // exposition only template<bool Const> using inner-sentinel = sentinel_t<maybe-const<Const, InnerView>>; // exposition only // [range.adjacent.transform.iterator], class template adjacent_­transform_­view​::​iterator template<bool> class iterator; // exposition only // [range.adjacent.transform.sentinel], class template adjacent_­transform_­view​::​sentinel template<bool> class sentinel; // exposition only public: adjacent_transform_view() = default; constexpr explicit adjacent_transform_view(V base, F fun); constexpr auto begin() { return iterator<false>(*this, inner_.begin()); } constexpr auto begin() const requires range<const InnerView> && regular_­invocable<const F&, REPEAT(range_reference_t<const V>, N)...> { return iterator<true>(*this, inner_.begin()); } constexpr auto end() { if constexpr (common_­range<InnerView>) { return iterator<false>(*this, inner_.end()); } else { return sentinel<false>(inner_.end()); } } constexpr auto end() const requires range<const InnerView> && regular_­invocable<const F&, REPEAT(range_reference_t<const V>, N)...> { if constexpr (common_­range<const InnerView>) { return iterator<true>(*this, inner_.end()); } else { return sentinel<true>(inner_.end()); } } constexpr auto size() requires sized_­range<InnerView> { return inner_.size(); } constexpr auto size() const requires sized_­range<const InnerView> { return inner_.size(); } }; }
constexpr explicit adjacent_transform_view(V base, F fun);
Effects: Initializes fun_­ with std​::​move(fun) and inner_­ with std​::​move(base).