[libcxx-commits] [PATCH] D103493: [libcxx][ranges] Add concepts in range.utility.helpers.

Arthur O'Dwyer via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Tue Jun 1 16:54:11 PDT 2021


Quuxplusone added inline comments.


================
Comment at: libcxx/test/libcxx/ranges/range.utility.helpers/simple_view.compile.pass.cpp:29-32
+struct NoConstView : std::ranges::view_base {
+  friend int* begin(NoConstView&);
+  friend int* end(NoConstView&);
+};
----------------
zoecarver wrote:
> Quuxplusone wrote:
> > I suggest you add a positive example `OnlyConstView`, with only `friend const int* begin(const OnlyConstView&)`.
> > And then you can eliminate lines 40 and 42 from `DifferentSentinel`.
> This isn't a view. A view requires that T is movable (i.e., not const) and that we can do `ranges::begin(declval<T&>())`. Therefor, we need all four members.
@zoecarver: I believe you've misunderstood. I'm asking that you add this test case:
```
struct OnlyConstView : std::ranges::view_base {
  friend int* begin(const OnlyConstView&);
  friend int* end(const OnlyConstView&);
};
static_assert(std::ranges::__simple_view<OnlyConstView>);
```
And then modify `DifferentSentinel` as follows:
```
struct DifferentSentinel : std::ranges::view_base {
  friend int* begin(DifferentSentinel const&);
  friend sentinel_wrapper<int*> end(DifferentSentinel const&);
};
static_assert(!std::ranges::__simple_view<DifferentSentinel>);
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103493



More information about the libcxx-commits mailing list