diff options
author | Marshall Clow <mclow.lists@gmail.com> | 2018-01-15 17:20:36 +0000 |
---|---|---|
committer | Marshall Clow <mclow.lists@gmail.com> | 2018-01-15 17:20:36 +0000 |
commit | 706ffef713a394b264ca1d4e8b8fa8d1aa38095b (patch) | |
tree | dd37bab74c4ec874c10884fef7208e8d822cf7dc /libcxx/test/std/algorithms/alg.nonmodifying | |
parent | 8a3735c00695fe43558f4842a3609c519ee1ebb2 (diff) | |
download | bcm5719-llvm-706ffef713a394b264ca1d4e8b8fa8d1aa38095b.tar.gz bcm5719-llvm-706ffef713a394b264ca1d4e8b8fa8d1aa38095b.zip |
More constexpr algorithms from P0202. any_of/all_of/none_of.
llvm-svn: 322492
Diffstat (limited to 'libcxx/test/std/algorithms/alg.nonmodifying')
3 files changed, 48 insertions, 3 deletions
diff --git a/libcxx/test/std/algorithms/alg.nonmodifying/alg.all_of/all_of.pass.cpp b/libcxx/test/std/algorithms/alg.nonmodifying/alg.all_of/all_of.pass.cpp index c3c34808819..5896b40ae96 100644 --- a/libcxx/test/std/algorithms/alg.nonmodifying/alg.all_of/all_of.pass.cpp +++ b/libcxx/test/std/algorithms/alg.nonmodifying/alg.all_of/all_of.pass.cpp @@ -16,16 +16,27 @@ #include <algorithm> #include <cassert> +#include "test_macros.h" #include "test_iterators.h" struct test1 { - bool operator()(const int& i) const + TEST_CONSTEXPR bool operator()(const int& i) const { return i % 2 == 0; } }; +#if TEST_STD_VER > 17 +TEST_CONSTEXPR int test_constexpr() { + int ia[] = {2, 4, 6, 8}; + int ib[] = {2, 4, 5, 8}; + return std::all_of(std::begin(ia), std::end(ia), test1()) + && !std::all_of(std::begin(ib), std::end(ib), test1()) + ; + } +#endif + int main() { { @@ -44,4 +55,8 @@ int main() assert(std::all_of(input_iterator<const int*>(ia), input_iterator<const int*>(ia), test1()) == true); } + +#if TEST_STD_VER > 17 + static_assert(test_constexpr()); +#endif } diff --git a/libcxx/test/std/algorithms/alg.nonmodifying/alg.any_of/any_of.pass.cpp b/libcxx/test/std/algorithms/alg.nonmodifying/alg.any_of/any_of.pass.cpp index d096e20d2d2..5256270a381 100644 --- a/libcxx/test/std/algorithms/alg.nonmodifying/alg.any_of/any_of.pass.cpp +++ b/libcxx/test/std/algorithms/alg.nonmodifying/alg.any_of/any_of.pass.cpp @@ -16,16 +16,27 @@ #include <algorithm> #include <cassert> +#include "test_macros.h" #include "test_iterators.h" struct test1 { - bool operator()(const int& i) const + TEST_CONSTEXPR bool operator()(const int& i) const { return i % 2 == 0; } }; +#if TEST_STD_VER > 17 +TEST_CONSTEXPR int test_constexpr() { + int ia[] = {2, 4, 6, 8}; + int ib[] = {1, 3, 5, 7}; + return std::any_of(std::begin(ia), std::end(ia), test1()) + && !std::any_of(std::begin(ib), std::end(ib), test1()) + ; + } +#endif + int main() { { @@ -52,4 +63,8 @@ int main() assert(std::any_of(input_iterator<const int*>(ia), input_iterator<const int*>(ia), test1()) == false); } + +#if TEST_STD_VER > 17 + static_assert(test_constexpr()); +#endif } diff --git a/libcxx/test/std/algorithms/alg.nonmodifying/alg.none_of/none_of.pass.cpp b/libcxx/test/std/algorithms/alg.nonmodifying/alg.none_of/none_of.pass.cpp index f4ea161891b..f3b8e778168 100644 --- a/libcxx/test/std/algorithms/alg.nonmodifying/alg.none_of/none_of.pass.cpp +++ b/libcxx/test/std/algorithms/alg.nonmodifying/alg.none_of/none_of.pass.cpp @@ -16,16 +16,27 @@ #include <algorithm> #include <cassert> +#include "test_macros.h" #include "test_iterators.h" struct test1 { - bool operator()(const int& i) const + TEST_CONSTEXPR bool operator()(const int& i) const { return i % 2 == 0; } }; +#if TEST_STD_VER > 17 +TEST_CONSTEXPR int test_constexpr() { + int ia[] = {1, 3, 6, 7}; + int ib[] = {1, 3, 5, 7}; + return !std::none_of(std::begin(ia), std::end(ia), test1()) + && std::none_of(std::begin(ib), std::end(ib), test1()) + ; + } +#endif + int main() { { @@ -52,4 +63,8 @@ int main() assert(std::none_of(input_iterator<const int*>(ia), input_iterator<const int*>(ia), test1()) == true); } + +#if TEST_STD_VER > 17 + static_assert(test_constexpr()); +#endif } |