[libcxx-commits] [PATCH] D142811: [libcxx][ranges] revert join_view::iterator and sentinel to be in-class

Hui via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Mon Jan 30 14:55:32 PST 2023


huixie90 added inline comments.


================
Comment at: libcxx/include/__ranges/join_view.h:184
+  template <class _Tp>
+  struct __is_join_view_iterator_checker{
+    static false_type __check();
----------------
ldionne wrote:
> huixie90 wrote:
> > philnik wrote:
> > > This seems quite complicated. Is there a reason not to use `__is_primary_template` instead?
> > I think the idea is exactly the same (the sfinae technique is also exactly the same but I did not know it is abstracted in _IsValidExpansion). but __is_primary_template does not sound the right name
> Can't we simply give this a private member called `__is_join_view_iterator` and check whether that member exists from a befriended class?
@ldionne 
That was the first thing I tried.

https://godbolt.org/z/Ws3baE1E1

It did not work because, even though `Derived` does not have access `Base::flag`. the friend `Checker` can still access `Derived::flag` as the `flag` is part of the `Base` sub object.

today I realised that I can make the befriended thing a template and only friend the particular instantiation.
https://godbolt.org/z/771rjzvzq

what do you think?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142811



More information about the libcxx-commits mailing list