[PATCH] D33997: Implement the non-execution policy versions of `reduce` and `transform_reduce` for C++17

Bryce Adelstein Lelbach via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 8 15:51:41 PDT 2017


wash added a comment.

I think we need a test case like this for all of the `transform_*`s

  struct A {};
  struct B {};
  struct C {};
  
  B unary_op(C);
  B unary_op(A) { assert(false); /* unary op applied to init value! */ }
  A binary_op(A, A);
  A binary_op(A, B);
  A binary_op(B, A);
  A binary_op(B, B); 
  
  std::vector<C> v;
  std::tranform_reduce(v.begin(), v.end(), A{}, binary_op, unary_op);

The "inner" transform operation should **never** be applied to the `init` parameter.



================
Comment at: include/numeric:209
+{
+	return transform_reduce(__first1, __last1, __first2, __init, _VSTD::plus<>(), _VSTD::multiplies<>());
+}
----------------
rsmith wrote:
> Missing _VSTD::
In the patch I downloaded from here, the spacing before the return is tabs, not spaces.


================
Comment at: test/std/numerics/numeric.ops/transform.reduce/transform_reduce_iter_iter_init_bop_uop.pass.cpp:44
+{
+  	constexpr const _Tp operator()(const _Tp& __x) const noexcept { return 2 * __x; }
+};
----------------
In the patch I downloaded from here, there is a tab right before `constexpr`.


https://reviews.llvm.org/D33997





More information about the cfe-commits mailing list