[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 12:50:55 PDT 2017


wash added a comment.

I think the test `reduce_iter_iter_T.pass.cpp` can be improved a little bit.

Right now, it:

- Tests that the three argument overload (iterators + init) work correctly when the iterator value type is the same as the init type.
- Tests that the return type of the three argument overload is correct in cases where the iterator value type differs from the init type.

It does not, however, test whether the result is correct when the iterator value type differs from the init type.

I'd suggest:

  void
  test_different_init_type()
  {
      char ca[] = {CHAR_MAX, CHAR_MAX, CHAR_MAX, CHAR_MAX};
      unsigned sa = sizeof(ca) / sizeof(ca[0]);
      test(ca, ca, int{0}, int{0});
      test(ca, ca+1, int{0}, int{CHAR_MAX});
      test(ca, ca+2, int{0}, int{2*CHAR_MAX});
      test(ca, ca+sa, int{0}, int{4*CHAR_MAX});
  }


https://reviews.llvm.org/D33997





More information about the cfe-commits mailing list