From 13c90a57165be999c505cfcfaf38755ed518b103 Mon Sep 17 00:00:00 2001 From: Louis Dionne Date: Wed, 6 Nov 2019 12:02:41 +0000 Subject: [libc++][P0202] Marked algorithms copy/copy_n/copy_if/copy_backward constexpr Thanks to Michael Park for the patch. Differential Revision: https://reviews.llvm.org/D68837 --- .../alg.copy/copy_n.pass.cpp | 100 ++++++++++----------- 1 file changed, 48 insertions(+), 52 deletions(-) (limited to 'libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/copy_n.pass.cpp') diff --git a/libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/copy_n.pass.cpp b/libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/copy_n.pass.cpp index 027dedcdc9b..179e4f1bb34 100644 --- a/libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/copy_n.pass.cpp +++ b/libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/copy_n.pass.cpp @@ -19,23 +19,11 @@ #include "test_iterators.h" #include "user_defined_integral.h" -// #if TEST_STD_VER > 17 -// TEST_CONSTEXPR bool test_constexpr() { -// int ia[] = {1, 2, 3, 4, 5}; -// int ic[] = {6, 6, 6, 6, 6, 6, 6}; -// -// auto p = std::copy_n(std::begin(ia), 4, std::begin(ic)); -// return std::equal(std::begin(ic), p, std::begin(ia)) -// && std::all_of(p, std::end(ic), [](int a){return a == 6;}) -// ; -// } -// #endif - typedef UserDefinedIntegral UDI; template -void -test() +TEST_CONSTEXPR_CXX20 void +test_copy_n() { const unsigned N = 1000; int ia[N]; @@ -49,46 +37,54 @@ test() assert(ia[i] == ib[i]); } +TEST_CONSTEXPR_CXX20 bool +test() +{ + test_copy_n, output_iterator >(); + test_copy_n, input_iterator >(); + test_copy_n, forward_iterator >(); + test_copy_n, bidirectional_iterator >(); + test_copy_n, random_access_iterator >(); + test_copy_n, int*>(); + + test_copy_n, output_iterator >(); + test_copy_n, input_iterator >(); + test_copy_n, forward_iterator >(); + test_copy_n, bidirectional_iterator >(); + test_copy_n, random_access_iterator >(); + test_copy_n, int*>(); + + test_copy_n, output_iterator >(); + test_copy_n, input_iterator >(); + test_copy_n, forward_iterator >(); + test_copy_n, bidirectional_iterator >(); + test_copy_n, random_access_iterator >(); + test_copy_n, int*>(); + + test_copy_n, output_iterator >(); + test_copy_n, input_iterator >(); + test_copy_n, forward_iterator >(); + test_copy_n, bidirectional_iterator >(); + test_copy_n, random_access_iterator >(); + test_copy_n, int*>(); + + test_copy_n >(); + test_copy_n >(); + test_copy_n >(); + test_copy_n >(); + test_copy_n >(); + test_copy_n(); + + return true; +} + int main(int, char**) { - test, output_iterator >(); - test, input_iterator >(); - test, forward_iterator >(); - test, bidirectional_iterator >(); - test, random_access_iterator >(); - test, int*>(); - - test, output_iterator >(); - test, input_iterator >(); - test, forward_iterator >(); - test, bidirectional_iterator >(); - test, random_access_iterator >(); - test, int*>(); - - test, output_iterator >(); - test, input_iterator >(); - test, forward_iterator >(); - test, bidirectional_iterator >(); - test, random_access_iterator >(); - test, int*>(); - - test, output_iterator >(); - test, input_iterator >(); - test, forward_iterator >(); - test, bidirectional_iterator >(); - test, random_access_iterator >(); - test, int*>(); - - test >(); - test >(); - test >(); - test >(); - test >(); - test(); - -// #if TEST_STD_VER > 17 -// static_assert(test_constexpr()); -// #endif + test(); + +#if TEST_STD_VER > 17 + static_assert(test()); +#endif return 0; } -- cgit v1.2.3