summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/algorithms/alg.modifying.operations
diff options
context:
space:
mode:
Diffstat (limited to 'libcxx/test/std/algorithms/alg.modifying.operations')
-rw-r--r--libcxx/test/std/algorithms/alg.modifying.operations/alg.partitions/is_partitioned.pass.cpp19
1 files changed, 17 insertions, 2 deletions
diff --git a/libcxx/test/std/algorithms/alg.modifying.operations/alg.partitions/is_partitioned.pass.cpp b/libcxx/test/std/algorithms/alg.modifying.operations/alg.partitions/is_partitioned.pass.cpp
index 8597b08da8c..eb9be71c2b5 100644
--- a/libcxx/test/std/algorithms/alg.modifying.operations/alg.partitions/is_partitioned.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.modifying.operations/alg.partitions/is_partitioned.pass.cpp
@@ -10,7 +10,7 @@
// <algorithm>
// template <class InputIterator, class Predicate>
-// bool
+// constpexr bool // constexpr after C++17
// is_partitioned(InputIterator first, InputIterator last, Predicate pred);
#include <algorithm>
@@ -18,13 +18,24 @@
#include <cstddef>
#include <cassert>
+#include "test_macros.h"
#include "test_iterators.h"
#include "counting_predicates.hpp"
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 int test_constexpr() {
+ int ia[] = {1, 3, 5, 2, 4, 6};
+ int ib[] = {1, 2, 3, 4, 5, 6};
+ return std::is_partitioned(std::begin(ia), std::end(ia), is_odd())
+ && !std::is_partitioned(std::begin(ib), std::end(ib), is_odd());
+ }
+#endif
+
+
int main() {
{
const int ia[] = {1, 2, 3, 4, 5, 6};
@@ -80,4 +91,8 @@ int main() {
assert(static_cast<std::ptrdiff_t>(pred.count()) <=
std::distance(std::begin(ia), std::end(ia)));
}
+
+#if TEST_STD_VER > 17
+ static_assert(test_constexpr());
+#endif
}
OpenPOWER on IntegriCloud