std::ranges::views::zip_transform, std::ranges::zip_transform_view
<ranges>
requires (ranges::view <Views> && ...) && (sizeof...(Views) > 0) &&
std::is_object_v <F> && std::regular_invocable <
F&, ranges::range_reference_t <Views>...> &&
/*can-reference*/<std::invoke_result_t <
F&, ranges::range_reference_t <Views>...>>
class zip_transform_view
inline constexpr /*unspecified*/ zip_transform = /*unspecified*/;
requires /* see below */
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.views::zip_transform
is a customization point object.
When calling with one argument f, let FD
be std::decay_t <decltype(f)>, if:
-
FD
modelscopy_constructible
, - FD& models
regular_invocable
, and - std::invoke_result_t <FD&> is an object type,
then 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.
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.
Contents
Customization point objects
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.
[edit] Member functions
sized_range
(public member function) [edit]
Inherited from std::ranges::view_interface
sized_range
or forward_range
(public member function of
std::ranges::view_interface<D>
) [edit]
(public member function of
std::ranges::view_interface<D>
) [edit]
(public member function of
std::ranges::view_interface<D>
) [edit]
(public member function of
std::ranges::view_interface<D>
) [edit]
forward_range
(public member function of
std::ranges::view_interface<D>
) [edit]
bidirectional_range
and common_range
(public member function of
std::ranges::view_interface<D>
) [edit]
n
th element in the derived view, provided only if it satisfies random_access_range
(public member function of
std::ranges::view_interface<D>
) [edit]
[edit] Deduction guides
[edit] Member types
ziperator
(private)
- ranges::iterator_t <const InnerView> if Const is true, otherwise
- ranges::iterator_t <InnerView>.
(exposition-only member type*)
zentinel
(private)
- ranges::sentinel_t <const InnerView> if Const is true, otherwise
- ranges::sentinel_t <InnerView>.
(exposition-only member type*)
[edit] Data members
zip_
(private)
An underlying view object of type InnerView
(exposition-only member object*)
[edit] Nested classes
zip_view
is not a common_range
(exposition-only member class template*)
[edit] Notes
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 |
[edit] Example
#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
view
consisting of tuples of references to corresponding elements of the adapted views(class template) (customization point object)[edit]
view
of a sequence that applies a transformation function to each element(class template) (range adaptor object)[edit]
view
consisting of tuple-like values and a number N and produces a view
of Nth element of each tuple(class template) (range adaptor object)[edit]