Created on 2022-07-13.00:00:00 last changed 4 weeks ago
This wording is relative to N4910.
Modify [range.adjacent.overview] as indicated:
-2- The name views::adjacent<N> denotes a range adaptor object ([range.adaptor.object]). Given a subexpression E and a constant expression N, the expression views::adjacent<N>(E) is expression-equivalent to:
((void)E, auto(views::empty<tuple<>>)) if N is equal to 0,
otherwise, adjacent_view<views::all_t<decltype((E))>, N>(E).
Modify [range.adjacent.transform.overview] as indicated:
-2- The name views::adjacent_transform<N> 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, 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.
(2.2) — 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).
views::adjacent is very similar to views::slide, except that the window size N is given at compile time.Since the case where N is 0 does not make sense for slide_view, LWG 3711 and LWG 3712 added preconditions to the constructor and removed the default constructor, respectively. But for views::adjacent, we can still specify N to be 0. According to the description of [range.adjacent.overview], it will return views::empty<tuple<>> as in the case of views::zip applied to an empty pack. And for views::adjacent_transform<0>(E, F), it will return views::zip_transform(F) and eventually return empty_view for some type. This doesn't seem reasonable to me. The reason why views::zip can return views::empty<tuple<>> is that the parameter pack can indeed be empty, so this still makes some sense. However, there is no meaningful sense for the word "adjacent" when N is 0. I don't see any observable value in allowing views::adjacent<0>, we should disable it for consistency with views::slide.
|2022-07-16 12:18:12||admin||set||messages: + msg12584|