zip_transform_view
is a range adaptor that takes an invocable object and one or more
view
s
, and produces a
view
whose
i
th
element is the result of applying the invocable object to the
i
th
elements of all views.
A type
T
models the exposition-only concept
/*can-reference*/if and only if
T&
is a valid type.
2)views::zip_transform
is a customization point object.
When calling with one argument f, let FD
be std::decay_t<decltype(f)>, if:
FD
models copy_constructible
,regular_invocable
, andthen views::zip_transform(f) is expression-equivalent to ((void)f, auto(views::empty<std::decay_t<std::invoke_result_t<FD&>>>)). Otherwise, the call to views::zip_transform
is ill-formed.
When calling with more than one arguments
fand
rs...,
views::zip_transform(f, rs...)is
expression-equivalentto
ranges::zip_transform_view(f, rs...).
zip_transform_view
models the concepts random_access_range
, bidirectional_range
, forward_range
, input_range
, common_range
, and sized_range
when the underlying ranges::zip_view<Views...> models respective concepts.
The name views::zip_transform
denotes a customization point object, which is a const function object of a literal semiregular
class type. See CustomizationPointObject for details.
zip_transform_view
sized_range
sized_range
or forward_range
std::ranges::view_interface<D>
) [edit] returns a constant iterator to the beginning of the range
std::ranges::view_interface<D>
) [edit] returns a sentinel for the constant iterator of the range
std::ranges::view_interface<D>
) [edit] returns whether the derived view is not empty, provided only if ranges::empty is applicable to it
std::ranges::view_interface<D>
) [edit] returns the first element in the derived view, provided if it satisfies forward_range
std::ranges::view_interface<D>
) [edit] returns the last element in the derived view, provided only if it satisfies bidirectional_range
and common_range
std::ranges::view_interface<D>
) [edit] returns the n
th element in the derived view, provided only if it satisfies random_access_range
std::ranges::view_interface<D>
) [edit] [edit] Deduction guides [edit] Member types [edit] Data members Member object Definition zip_
(private) An underlying view object of type InnerView
fun_
(private) A wrapped invocable object of type movable-box<F>
zip_view
is not a common_range
#include <array> #include <iostream> #include <list> #include <ranges> #include <vector> void print(auto const rem, auto const& r) { std::cout << rem << '{'; for (char o[]{0,' ',0}; auto const& 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}[edit] See also
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4