[libcxx-commits] [PATCH] D90569: [RFC] [libc++] P1645 constexpr for <numeric>

Louis Dionne via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Tue Nov 3 05:42:27 PST 2020


ldionne requested changes to this revision.
ldionne added a comment.
This revision now requires changes to proceed.

> Or do you prefer small patches per function? (In that case I'll to update the status since it now expects one patch.)

One patch for all is fine. But it's a good idea to iterate on this one function for now until we are good to go, and then you can do the other ones. This will avoid back and forth.



================
Comment at: libcxx/include/numeric:20
 template <class InputIterator, class T>
-    T
+    constexpr T
     accumulate(InputIterator first, InputIterator last, T init);
----------------
Please add `// constexpr since C++20` to note that the API is only constexpr in C++20.


================
Comment at: libcxx/test/std/numerics/numeric.ops/accumulate/accumulate.pass.cpp:76
 {
-    test<input_iterator<const int*> >();
-    test<forward_iterator<const int*> >();
-    test<bidirectional_iterator<const int*> >();
-    test<random_access_iterator<const int*> >();
-    test<const int*>();
+#if _LIBCPP_STD_VER > 17
+    constexpr_test<input_iterator<const int*> >();
----------------
The tests for runtime and constexpr should be the same. Can you please take a look at `libcxx/test/std/utilities/memory/specialized.algorithms/specialized.destroy/destroy_n.pass.cpp` to see how we do it elsewhere?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90569



More information about the libcxx-commits mailing list