[PATCH] D33997: Implement the non-execution policy versions of `reduce` and `transform_reduce` for C++17
Marshall Clow via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sat Jun 10 13:52:39 PDT 2017
mclow.lists marked 7 inline comments as done.
mclow.lists added inline comments.
================
Comment at: include/numeric:154
+ return reduce(__first, __last,
+ typename iterator_traits<_InputIterator>::value_type{}, _VSTD::plus<>());
+}
----------------
wash wrote:
> In the spec, this overload of `reduce` is described as equivalent to `return reduce(std::forward<ExecutionPolicy>(exec), first, last, typename iterator_traits<ForwardIterator>::value_type{});`. The overload that it calls (the three argument version that omits a binary operation) just forwards to the four-argument reduce, adding the `plus<>()` argument.
>
> Is there a reason you wanted to avoid the extra layer of function call indirection (it should be inlined and optimized away, right)? What you have seems perfectly fine, I'm just curious though.
Nah. Just eager on the copy/paste.
================
Comment at: test/std/numerics/numeric.ops/transform.reduce/transform_reduce_iter_iter_init_bop_uop.pass.cpp:36
+ _NOEXCEPT_(noexcept(_VSTD::forward<_Tp>(__x)))
+ -> decltype (_VSTD::forward<_Tp>(__x))
+ { return _VSTD::forward<_Tp>(__x); }
----------------
rsmith wrote:
> Maybe use `decltype(auto)` here?
I copied this formulation from `<functional>` where we use it all over the place ;-)
(but that's because we support old standards)
https://reviews.llvm.org/D33997
More information about the cfe-commits
mailing list