diff options
author | Marshall Clow <mclow.lists@gmail.com> | 2018-01-15 16:16:32 +0000 |
---|---|---|
committer | Marshall Clow <mclow.lists@gmail.com> | 2018-01-15 16:16:32 +0000 |
commit | 49c7643c39b0adb6ec88528ad7da01dd82deb84b (patch) | |
tree | 297a49e441a71c80d48a14088679bb3e14f459c2 /libcxx/test/std/algorithms/alg.modifying.operations | |
parent | 776a81a483da73b52f8d73ce441b0f03dbf5411b (diff) | |
download | bcm5719-llvm-49c7643c39b0adb6ec88528ad7da01dd82deb84b.tar.gz bcm5719-llvm-49c7643c39b0adb6ec88528ad7da01dd82deb84b.zip |
First part of P0202: Adding constexpr modifiers to functions in <algorithm> and <utility>. This commit is all the is_XXX algorithms.
llvm-svn: 322489
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.cpp | 19 |
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 } |