diff options
author | Louis Dionne <ldionne@apple.com> | 2019-11-06 12:02:41 +0000 |
---|---|---|
committer | Louis Dionne <ldionne@apple.com> | 2019-11-06 12:02:41 +0000 |
commit | 13c90a57165be999c505cfcfaf38755ed518b103 (patch) | |
tree | 5a0954ac9f779f93f0701902015bbdbed3dd2605 /libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/copy.pass.cpp | |
parent | eb12b3b8a3e5f41a6ab84f94dfc85551f92bc2ea (diff) | |
download | bcm5719-llvm-13c90a57165be999c505cfcfaf38755ed518b103.tar.gz bcm5719-llvm-13c90a57165be999c505cfcfaf38755ed518b103.zip |
[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
Diffstat (limited to 'libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/copy.pass.cpp')
-rw-r--r-- | libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/copy.pass.cpp | 92 |
1 files changed, 44 insertions, 48 deletions
diff --git a/libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/copy.pass.cpp b/libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/copy.pass.cpp index 9dcace7a03d..cc99859d8a7 100644 --- a/libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/copy.pass.cpp +++ b/libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/copy.pass.cpp @@ -18,21 +18,9 @@ #include "test_macros.h" #include "test_iterators.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(std::begin(ia), std::end(ia), std::begin(ic)); -// return std::equal(std::begin(ia), std::end(ia), std::begin(ic), p) -// && std::all_of(p, std::end(ic), [](int a){return a == 6;}) -// ; -// } -// #endif - template <class InIter, class OutIter> -void -test() +TEST_CONSTEXPR_CXX20 void +test_copy() { const unsigned N = 1000; int ia[N]; @@ -46,46 +34,54 @@ test() assert(ia[i] == ib[i]); } -int main(int, char**) +TEST_CONSTEXPR_CXX20 bool +test() { - test<input_iterator<const int*>, output_iterator<int*> >(); - test<input_iterator<const int*>, input_iterator<int*> >(); - test<input_iterator<const int*>, forward_iterator<int*> >(); - test<input_iterator<const int*>, bidirectional_iterator<int*> >(); - test<input_iterator<const int*>, random_access_iterator<int*> >(); - test<input_iterator<const int*>, int*>(); + test_copy<input_iterator<const int*>, output_iterator<int*> >(); + test_copy<input_iterator<const int*>, input_iterator<int*> >(); + test_copy<input_iterator<const int*>, forward_iterator<int*> >(); + test_copy<input_iterator<const int*>, bidirectional_iterator<int*> >(); + test_copy<input_iterator<const int*>, random_access_iterator<int*> >(); + test_copy<input_iterator<const int*>, int*>(); - test<forward_iterator<const int*>, output_iterator<int*> >(); - test<forward_iterator<const int*>, input_iterator<int*> >(); - test<forward_iterator<const int*>, forward_iterator<int*> >(); - test<forward_iterator<const int*>, bidirectional_iterator<int*> >(); - test<forward_iterator<const int*>, random_access_iterator<int*> >(); - test<forward_iterator<const int*>, int*>(); + test_copy<forward_iterator<const int*>, output_iterator<int*> >(); + test_copy<forward_iterator<const int*>, input_iterator<int*> >(); + test_copy<forward_iterator<const int*>, forward_iterator<int*> >(); + test_copy<forward_iterator<const int*>, bidirectional_iterator<int*> >(); + test_copy<forward_iterator<const int*>, random_access_iterator<int*> >(); + test_copy<forward_iterator<const int*>, int*>(); - test<bidirectional_iterator<const int*>, output_iterator<int*> >(); - test<bidirectional_iterator<const int*>, input_iterator<int*> >(); - test<bidirectional_iterator<const int*>, forward_iterator<int*> >(); - test<bidirectional_iterator<const int*>, bidirectional_iterator<int*> >(); - test<bidirectional_iterator<const int*>, random_access_iterator<int*> >(); - test<bidirectional_iterator<const int*>, int*>(); + test_copy<bidirectional_iterator<const int*>, output_iterator<int*> >(); + test_copy<bidirectional_iterator<const int*>, input_iterator<int*> >(); + test_copy<bidirectional_iterator<const int*>, forward_iterator<int*> >(); + test_copy<bidirectional_iterator<const int*>, bidirectional_iterator<int*> >(); + test_copy<bidirectional_iterator<const int*>, random_access_iterator<int*> >(); + test_copy<bidirectional_iterator<const int*>, int*>(); - test<random_access_iterator<const int*>, output_iterator<int*> >(); - test<random_access_iterator<const int*>, input_iterator<int*> >(); - test<random_access_iterator<const int*>, forward_iterator<int*> >(); - test<random_access_iterator<const int*>, bidirectional_iterator<int*> >(); - test<random_access_iterator<const int*>, random_access_iterator<int*> >(); - test<random_access_iterator<const int*>, int*>(); + test_copy<random_access_iterator<const int*>, output_iterator<int*> >(); + test_copy<random_access_iterator<const int*>, input_iterator<int*> >(); + test_copy<random_access_iterator<const int*>, forward_iterator<int*> >(); + test_copy<random_access_iterator<const int*>, bidirectional_iterator<int*> >(); + test_copy<random_access_iterator<const int*>, random_access_iterator<int*> >(); + test_copy<random_access_iterator<const int*>, int*>(); - test<const int*, output_iterator<int*> >(); - test<const int*, input_iterator<int*> >(); - test<const int*, forward_iterator<int*> >(); - test<const int*, bidirectional_iterator<int*> >(); - test<const int*, random_access_iterator<int*> >(); - test<const int*, int*>(); + test_copy<const int*, output_iterator<int*> >(); + test_copy<const int*, input_iterator<int*> >(); + test_copy<const int*, forward_iterator<int*> >(); + test_copy<const int*, bidirectional_iterator<int*> >(); + test_copy<const int*, random_access_iterator<int*> >(); + test_copy<const int*, int*>(); + + return true; +} + +int main(int, char**) +{ + test(); -// #if TEST_STD_VER > 17 -// static_assert(test_constexpr()); -// #endif +#if TEST_STD_VER > 17 + static_assert(test()); +#endif return 0; } |