[libcxx-commits] [PATCH] D68837: [libc++][P0202] Marked algorithms copy/copy_n/copy_if/copy_backward constexpr.

Zoe Carver via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Thu Oct 10 21:56:12 PDT 2019


zoecarver added a comment.

`__libcpp_is_constant_evaluated` returns `false` in C++03 mode but, it still won't work as a template argument. Putting `#if`s around it will probably work, though.



================
Comment at: libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/copy.pass.cpp:22
+#if TEST_STD_VER > 17
+TEST_CONSTEXPR bool test_constexpr()
+{
----------------
It seems like these were already here. I think it would be really great if we could instead have a single test. For all these algorithms, what I would ideally like is just to change the return type to `bool`, add `constexpr`, and `return true` at the end. Then we can `static_assert` that `test` succeeds. If `assert` fails in the test, the `static_assert` will also fail. 

Maybe we can even develop a macro to wrap these functions and run them in both constexpr mode and normally. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68837





More information about the libcxx-commits mailing list