Files
2025-10-25 03:02:53 +03:00

2.0 KiB
Raw Permalink Blame History

[range.adjacent.transform.overview]

25 Ranges library [ranges]

25.7 Range adaptors [range.adaptors]

25.7.28 Adjacent transform view [range.adjacent.transform]

25.7.28.1 Overview [range.adjacent.transform.overview]

1

#

adjacent_transform_view takes an invocable object and a view and produces a view whose Mth element is the result of applying the invocable object to the Mth through (M+N−1)th elements of the original view.

If the original view has fewer than N elements, the resulting view is empty.

2

#

The name views::adjacent_transform denotes a range adaptor object ([range.adaptor.object]).

Given subexpressions E and F and a constant expression N:

  • (2.1)

    If N is equal to 0 anddecltype((E)) models forward_range,views::adjacent_transform(E, F) is expression-equivalent to((void)E, views::zip_transform(F)), except that the evaluations of E and F are indeterminately sequenced.

  • (2.2)

    Otherwise, the expression views::adjacent_transform(E, F) is expression-equivalent toadjacent_transform_view<views::all_t<decltype((E))>, decay_t<decltype((F))>, N>(E, F).

3

#

[Example 1: vector v = {1, 2, 3, 4};

for (auto i : v | views::adjacent_transform<2>(std::multiplies())) { cout << i << ' '; // prints 2 6 12} — end example]