diff options
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.cpp | 26 |
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 } |