diff options
author | Marshall Clow <mclow.lists@gmail.com> | 2018-01-22 21:43:04 +0000 |
---|---|---|
committer | Marshall Clow <mclow.lists@gmail.com> | 2018-01-22 21:43:04 +0000 |
commit | e8ea8296fccc6d9345817ece7d2f4ea3b35a55e1 (patch) | |
tree | 3f66bb53ae99e2106d2b00ec787616f85ed47fb0 /libcxx/test/std/algorithms/alg.modifying.operations/alg.reverse/reverse_copy.pass.cpp | |
parent | d2a9592526147bb96103fca21912e0ac40537965 (diff) | |
download | bcm5719-llvm-e8ea8296fccc6d9345817ece7d2f4ea3b35a55e1.tar.gz bcm5719-llvm-e8ea8296fccc6d9345817ece7d2f4ea3b35a55e1.zip |
Another batch of P0202 constepr algirithms. remove/remove_if/remove_copy/remove_copy_if/reverse_copy, and tests (commented out) for rotate_copy, because that depends on std::copy
llvm-svn: 323152
Diffstat (limited to 'libcxx/test/std/algorithms/alg.modifying.operations/alg.reverse/reverse_copy.pass.cpp')
-rw-r--r-- | libcxx/test/std/algorithms/alg.modifying.operations/alg.reverse/reverse_copy.pass.cpp | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/libcxx/test/std/algorithms/alg.modifying.operations/alg.reverse/reverse_copy.pass.cpp b/libcxx/test/std/algorithms/alg.modifying.operations/alg.reverse/reverse_copy.pass.cpp index 70840d187bf..ec9aa9e94ab 100644 --- a/libcxx/test/std/algorithms/alg.modifying.operations/alg.reverse/reverse_copy.pass.cpp +++ b/libcxx/test/std/algorithms/alg.modifying.operations/alg.reverse/reverse_copy.pass.cpp @@ -10,14 +10,28 @@ // <algorithm> // template<BidirectionalIterator InIter, OutputIterator<auto, InIter::reference> OutIter> -// OutIter +// constexpr OutIter // constexpr after C++17 // reverse_copy(InIter first, InIter last, OutIter result); #include <algorithm> #include <cassert> +#include "test_macros.h" #include "test_iterators.h" +#if TEST_STD_VER > 17 +TEST_CONSTEXPR bool test_constexpr() { + int ia[] = {1, 3, 5, 2, 5, 6}; + int ib[std::size(ia)] = {0}; + + auto it = std::reverse_copy(std::begin(ia), std::end(ia), std::begin(ib)); + + return std::distance(std::begin(ib), it) == std::size(ia) + && std::equal (std::begin(ia), std::end(ia), std::rbegin(ib)) + ; + } +#endif + template <class InIter, class OutIter> void test() @@ -78,4 +92,8 @@ int main() test<const int*, bidirectional_iterator<int*> >(); test<const int*, random_access_iterator<int*> >(); test<const int*, int*>(); + +#if TEST_STD_VER > 17 + static_assert(test_constexpr()); +#endif } |