[PATCH] D106605: Add `all_of_zip` to STLExtras

David Blaikie via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 28 12:09:45 PDT 2021


dblaikie added a comment.

In D106605#2908016 <https://reviews.llvm.org/D106605#2908016>, @mehdi_amini wrote:

>> What about if the range itself was boolean testable (or had some "areBothRangesTraversed" operation or the like) that could be queried (assert-fails if queried early) after the zip has reached the end (and in that case the end would be the end of either range, whichever comes first)?
>
> That's interesting: the range itself is disconnected from the iterator state though, so I don't think you could just query the range.
>
> The best I can think of would be something that would end-up looking like:
>
>   auto range = zip(a, b, c);
>   auto it = range.begin();
>   for (; it != range.end(); ++it) {
>      ...
>   }
>   if (!it.all_equals(range.end())  // bike shed the API name
>      // error

Ah, yeah, fair enough. Looks OK.

Though I worry about the likely combinatorial expansion of the ultimate API, still - `all_of_zip` implies the likely existence of `none_of_zip` and `any_of_zip` - which admittedly can be defined in terms of one another, so it's not loads of duplication... eh, maybe that's OK then, if they get created.

Carry on!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106605/new/

https://reviews.llvm.org/D106605



More information about the llvm-commits mailing list