24 Ranges library [ranges]

24.7 Range adaptors [range.adaptors]

24.7.20 Zip transform view [range.zip.transform]

24.7.20.2 Class template zip_­transform_­view [range.zip.transform.view]

namespace std::ranges { template<copy_­constructible F, input_­range... Views> requires (view<Views> && ...) && (sizeof...(Views) > 0) && is_object_v<F> && regular_­invocable<F&, range_reference_t<Views>...> && can-reference<invoke_result_t<F&, range_reference_t<Views>...>> class zip_transform_view : public view_interface<zip_transform_view<F, Views...>> { copyable-box<F> fun_; // exposition only zip_view<Views...> zip_; // exposition only using InnerView = zip_view<Views...>; // exposition only template<bool Const> using ziperator = iterator_t<maybe-const<Const, InnerView>>; // exposition only template<bool Const> using zentinel = sentinel_t<maybe-const<Const, InnerView>>; // exposition only // [range.zip.transform.iterator], class template zip_­transform_­view​::​iterator template<bool> class iterator; // exposition only // [range.zip.transform.sentinel], class template zip_­transform_­view​::​sentinel template<bool> class sentinel; // exposition only public: zip_transform_view() = default; constexpr explicit zip_transform_view(F fun, Views... views); constexpr auto begin() { return iterator<false>(*this, zip_.begin()); } constexpr auto begin() const requires range<const InnerView> && regular_­invocable<const F&, range_reference_t<const Views>...> { return iterator<true>(*this, zip_.begin()); } constexpr auto end() { if constexpr (common_­range<InnerView>) { return iterator<false>(*this, zip_.end()); } else { return sentinel<false>(zip_.end()); } } constexpr auto end() const requires range<const InnerView> && regular_­invocable<const F&, range_reference_t<const Views>...> { if constexpr (common_­range<const InnerView>) { return iterator<true>(*this, zip_.end()); } else { return sentinel<true>(zip_.end()); } } constexpr auto size() requires sized_­range<InnerView> { return zip_.size(); } constexpr auto size() const requires sized_­range<const InnerView> { return zip_.size(); } }; template<class F, class... Rs> zip_transform_view(F, Rs&&...) -> zip_transform_view<F, views::all_t<Rs>...>; }
constexpr explicit zip_transform_view(F fun, Views... views);
Effects: Initializes fun_­ with std​::​move(fun) and zip_­ with std​::​move(views)....