summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/algorithms/alg.modifying.operations/alg.partitions/partition_copy.pass.cpp
diff options
context:
space:
mode:
authorMarshall Clow <mclow.lists@gmail.com>2018-01-22 20:44:33 +0000
committerMarshall Clow <mclow.lists@gmail.com>2018-01-22 20:44:33 +0000
commit1b9a4ffd6bb2622360e6bae10bbcce7348186e94 (patch)
tree5a14c13574c3b1180031bd6aefdc1427cf9446a8 /libcxx/test/std/algorithms/alg.modifying.operations/alg.partitions/partition_copy.pass.cpp
parentd7d991e881fb3f74325a13cc80cc5467eb43af65 (diff)
downloadbcm5719-llvm-1b9a4ffd6bb2622360e6bae10bbcce7348186e94.tar.gz
bcm5719-llvm-1b9a4ffd6bb2622360e6bae10bbcce7348186e94.zip
Still more P0202 constexpr-ifying. This batch is: for_each/for_each_n/lexicographical_compare
llvm-svn: 323147
Diffstat (limited to 'libcxx/test/std/algorithms/alg.modifying.operations/alg.partitions/partition_copy.pass.cpp')
-rw-r--r--libcxx/test/std/algorithms/alg.modifying.operations/alg.partitions/partition_copy.pass.cpp26
1 files changed, 24 insertions, 2 deletions
diff --git a/libcxx/test/std/algorithms/alg.modifying.operations/alg.partitions/partition_copy.pass.cpp b/libcxx/test/std/algorithms/alg.modifying.operations/alg.partitions/partition_copy.pass.cpp
index 67e1cccaf73..0fd24c1c3cb 100644
--- a/libcxx/test/std/algorithms/alg.modifying.operations/alg.partitions/partition_copy.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.modifying.operations/alg.partitions/partition_copy.pass.cpp
@@ -11,7 +11,7 @@
// template <class InputIterator, class OutputIterator1,
// class OutputIterator2, class Predicate>
-// pair<OutputIterator1, OutputIterator2>
+// constexpr pair<OutputIterator1, OutputIterator2> // constexpr after C++17
// partition_copy(InputIterator first, InputIterator last,
// OutputIterator1 out_true, OutputIterator2 out_false,
// Predicate pred);
@@ -19,13 +19,31 @@
#include <algorithm>
#include <cassert>
+#include "test_macros.h"
#include "test_iterators.h"
struct is_odd
{
- bool operator()(const int& i) const {return i & 1;}
+ TEST_CONSTEXPR bool operator()(const int& i) const {return i & 1;}
};
+#if TEST_STD_VER > 17
+TEST_CONSTEXPR bool test_constexpr() {
+ int ia[] = {1, 3, 5, 2, 4, 6};
+ int r1[10] = {0};
+ int r2[10] = {0};
+
+ auto p = std::partition_copy(std::begin(ia), std::end(ia),
+ std::begin(r1), std::begin(r2), is_odd());
+
+ return std::all_of(std::begin(r1), p.first, is_odd())
+ && std::all_of(p.first, std::end(r1), [](int a){return a == 0;})
+ && std::none_of(std::begin(r2), p.second, is_odd())
+ && std::all_of(p.second, std::end(r2), [](int a){return a == 0;})
+ ;
+ }
+#endif
+
int main()
{
{
@@ -47,4 +65,8 @@ int main()
assert(r2[2] == 6);
assert(r2[3] == 8);
}
+
+#if TEST_STD_VER > 17
+ static_assert(test_constexpr());
+#endif
}
OpenPOWER on IntegriCloud