[libcxx-commits] [PATCH] D102037: [libcxx][views] Add drop_view.
Tim Song via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Mon May 10 09:46:59 PDT 2021
tcanens added inline comments.
================
Comment at: libcxx/include/__ranges/drop_view.h:44
+ range_difference_t<_View> __count = 0;
+ iterator_t<_View> __cached_begin = ranges::begin(__base);
+
----------------
cjdb wrote:
> zoecarver wrote:
> > tcanens wrote:
> > > cjdb wrote:
> > > > tcanens wrote:
> > > > > tcanens wrote:
> > > > > > There's no requirement that `ranges::begin` on a default-constructed view is even well-defined (see: `ref_view`).
> > > > > >
> > > > > > Additionally, when a `drop_view` is copied, the cache must be invalidated in the copy.
> > > > > ...and when a `drop_view` is moved-from, the cache must be invalidated in the original.
> > > > @tcanens is this a non-propagating cache?
> > > Yep. This is the original use case of //`non-propagating-cache`// in range-v3.
> > Where in the standard does it say this is a non-propagating cache? Or is that what your paper does?
> The standard is very underspecified in what kind of cache is necessary here. I just checked, and range-v3 and cmcstl2 disagree on what kind of cache is necessary: range-v3 uses a non-propagating cache; cmcstl2 switches between a non-propagating cache and a simple cache, depending on whether or not we have a //`forwarding-range`// (which I think is now `borrowed_range`).
> I'm inclined to support Tim's opinion here, because it's simpler, and doesn't need to introduce a `__cached_position` type that's dependent on `__non_propagating_cache`. Any opinions @CaseyCarter?
> Where in the standard does it say this is a non-propagating cache? Or is that what your paper does?
It falls out of the fact that nothing in the standard allows "take a `drop_view`, call `begin()` on it, copy it, and call `begin()` on the copy" to not work.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D102037/new/
https://reviews.llvm.org/D102037
More information about the libcxx-commits
mailing list