24 Ranges library [ranges]

24.7 Range adaptors [range.adaptors]

24.7.22 Adjacent transform view [range.adjacent.transform] Overview [range.adjacent.transform.overview]

adjacent_­transform_­view takes an invocable object and a view and produces a view whose element is the result of applying the invocable object to the through elements of the original view.
If the original view has fewer than N elements, the resulting view is empty.
The name views​::​adjacent_­transform<N> denotes a range adaptor object ([range.adaptor.object]).
Given subexpressions E and F and a constant expression N:
  • If N is equal to 0, views​::​adjacent_­transform<N>(E, F) is expression-equivalent to ((void)E, views​::​zip_­transform(F)), except that the evaluations of E and F are indeterminately sequenced.
  • Otherwise, the expression views​::​adjacent_­transform<N>(E, F) is expression-equivalent to adjacent_­transform_­view<views​::​all_­t<decltype((E))>, decay_­t<decltype((F))>, N>(E, F).
[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]