[libcxx-commits] [PATCH] D103056: [libcxx][ranges] Add `ranges::transform_view`.

Tim Song via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed Jun 30 07:01:15 PDT 2021


tcanens added inline comments.


================
Comment at: libcxx/include/__ranges/transform_view.h:60-61
+
+  _View __base_ = _View();
+  __copyable_box<_Fn> __func_;
+
----------------
Quuxplusone wrote:
> tcanens wrote:
> > Quuxplusone wrote:
> > > My intuition is that you want to switch these around:
> > > ```
> > > [[no_unique_address]] __copyable_box<_Fn> __func_;
> > > _View __base_ = _View();
> > > ```
> > > However, I remember @tcanens having counterintuitive-but-correct intuitions about field ordering in other reviews. It would be useful to write those down as guidelines, somewhere. I volunteer to blog it, if someone can explain it to me until I remember it. :)
> > After LWG3549 this doesn't really matter.
> I don't think LWG3549 presents an alternative to `view_base` for non-libc++ programmers, though, does it? "Civilian" (albeit Niebler-level) programmers are still going to be writing classes that derive from `view_base`, and so if we're making any layout decisions based on that derivation, our decisions should be unaffected by LWG3549.
> I'm thinking of concerns like this:
> https://godbolt.org/z/nr9sjbqzn
> ...Or is the idea that civilians should never use `view_base`, they should always use `view_interface<CRTP>` instead? (In that case, `view_base` probably should never have been specified in the standard?)
View adaptors that use `view_base` are saying "I don't care about the potential extra padding". I don't really care about making a wrapped external thing work better with some other external wrapper - it's trying to save other people from themselves.

`view_base` is still handy for concrete views (that aren't adaptors).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103056



More information about the libcxx-commits mailing list