|
Range primitives | |||||||
|
Range concepts | |||||||||||||||||||
|
Range factories | |||||||||
|
Range adaptors | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
Helper items | |||||||||||||||||
|
Member functions | ||||
Deduction guides | ||||
Iterator | ||||
Member functions | ||||
Non-member functions | ||||
Sentinel | ||||
Member functions | ||||
Non-member functions | ||||
Defined in header <ranges> | ||
template<std::move_constructible F,ranges::input_range...Views> requires(ranges::view<Views>&& ...)&&(sizeof...(Views)>0)&& | (1) | (since C++23) |
namespace views{ inlineconstexpr/*unspecified*/ zip_transform=/*unspecified*/; | (2) | (since C++23) |
Call signature | ||
template<class F,ranges::viewable_range...Rs> requires/* see below */ | (since C++23) | |
zip_transform_view
is a range adaptor that takes an invocable object and one or moreview
s, and produces aview
whosei
th element is the result of applying the invocable object to thei
th elements of all views.T
models the exposition-only concept/*can-reference*/ if and only ifT&
is a valid type.views::zip_transform
is a customization point object.When calling with one argumentf, letFD
bestd::decay_t<decltype(f)>, if:
FD
modelscopy_constructible
,regular_invocable
, andthenviews::zip_transform(f) isexpression-equivalent to((void)f,auto(views::empty<std::decay_t<std::invoke_result_t<FD&>>>)). Otherwise, the call toviews::zip_transform
is ill-formed.
zip_transform_view
models the conceptsrandom_access_range
,bidirectional_range
,forward_range
,input_range
,common_range
, andsized_range
when the underlyingranges::zip_view<Views...> models respective concepts.
Contents |
The nameviews::zip_transform
denotes acustomization point object, which is a constfunction object of aliteralsemiregular
class type. SeeCustomizationPointObject for details.
constructs azip_transform_view (public member function)[edit] | |
returns an iterator to the beginning (public member function)[edit] | |
returns an iterator or a sentinel to the end (public member function)[edit] | |
returns the number of elements, provided only if each underlying (adapted) range satisfiessized_range (public member function)[edit] | |
Inherited fromstd::ranges::view_interface | |
returns whether the derived view is empty, provided only if it satisfiessized_range orforward_range (public member function of std::ranges::view_interface<D> )[edit] | |
(C++23) | returns a constant iterator to the beginning of the range (public member function of std::ranges::view_interface<D> )[edit] |
(C++23) | returns a sentinel for the constant iterator of the range (public member function of std::ranges::view_interface<D> )[edit] |
returns whether the derived view is not empty, provided only ifranges::empty is applicable to it (public member function of std::ranges::view_interface<D> )[edit] | |
returns the first element in the derived view, provided if it satisfiesforward_range (public member function of std::ranges::view_interface<D> )[edit] | |
returns the last element in the derived view, provided only if it satisfiesbidirectional_range andcommon_range (public member function of std::ranges::view_interface<D> )[edit] | |
returns then th element in the derived view, provided only if it satisfiesrandom_access_range (public member function of std::ranges::view_interface<D> )[edit] |
Member type | Definition |
InnerView (private) | ranges::zip_view<Views...>. (exposition-only member type*) |
ziperator (private) |
|
zentinel (private) |
|
Member object | Definition |
zip_ (private) | An underlying view object of typeInnerView (exposition-only member object*) |
fun_ (private) | A wrapped invocable object of typemovable-box<F> (exposition-only member object*) |
the iterator type (exposition-only member class template*) | |
the sentinel type used when the underlyingzip_view is not acommon_range (exposition-only member class template*) |
Feature-test macro | Value | Std | Feature |
---|---|---|---|
__cpp_lib_ranges_zip | 202110L | (C++23) | ranges::zip_view,std::ranges::zip_transform_view ,ranges::adjacent_view, ranges::adjacent_transform_view |
#include <array>#include <iostream>#include <list>#include <ranges>#include <vector> void print(autoconst rem,autoconst& r){std::cout<< rem<<'{';for(char o[]{0,' ',0};autoconst& e: r)std::cout<< o<< e,*o=',';std::cout<<"}\n";} int main(){auto v1=std::vector<float>{1,2,3};auto v2=std::list<short>{1,2,3,4};auto v3=std::to_array({1,2,3,4,5}); auto add=[](auto a,auto b,auto c){return a+ b+ c;}; auto sum= std::views::zip_transform(add, v1, v2, v3); print("v1: ", v1); print("v2: ", v2); print("v3: ", v3); print("sum: ", sum);}
Output:
v1: {1, 2, 3}v2: {1, 2, 3, 4}v3: {1, 2, 3, 4, 5}sum: {3, 6, 9}
(C++23) | aview consisting of tuples of references to corresponding elements of the adapted views(class template)(customization point object)[edit] |
aview of a sequence that applies a transformation function to each element(class template)(range adaptor object)[edit] | |
takes aview consisting oftuple-like values and a number N and produces aview of Nth element of each tuple(class template)(range adaptor object)[edit] |