[libcxx-commits] [PATCH] D104492: [libc++][pstl] Implement tag dispatching

Ruslan Arutyunyan via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Mon Jan 17 18:12:14 PST 2022


rarutyun added inline comments.


================
Comment at: pstl/include/pstl/internal/execution_impl.h:30-32
+__is_iterator_of(int) -> decltype(
+    std::conjunction<std::is_base_of<
+        _IteratorTag, typename std::iterator_traits<std::decay_t<_IteratorTypes>>::iterator_category>...>{});
----------------
Quuxplusone wrote:
> rarutyun wrote:
> > Quuxplusone wrote:
> > > `decltype(T{})` is just `T`.
> > There reason of `decltype` was SFINAE. `iterator_category` is not always the part of `iterator_traits`. I thought it might be useful when we adopt take this approach from PSTL upstream to oneDPL.
> > 
> > On the other hand, we don't have much to do when the passed types by users are not iterators. So, yeah, let's keep it simple. Probably if we need additional logic in our code we can make it in other place.
> IIUC, you were thinking that using the `decltype` syntax would somehow "enable" SFINAE. That's not the case. SFINAE is happening regardless of the syntax you use.
> ```
> template<class T> void f() -> decltype(typename T::nested_type{}) {}
> template<class T> void f() -> typename T::nested_type {}
> ```
> Both versions of `f` SFINAE away correctly when `T=int` (because substituting `int` into `T::nested_type` produces a failure, and substitution failure is not an error). The only thing that is different is that in the former case, we're also SFINAE-checking that `T::nested_type{}` is well-formed (i.e. `T::nested_type` is default-constructible from empty braces) whereas in the latter case we are checking only that it //exists//. (But this distinction shouldn't matter for tag types, which are always default-constructible.)
Yes, you are right. Anyway, we current implementation it is not required anymore.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104492



More information about the libcxx-commits mailing list