diff options
author | Marshall Clow <mclow.lists@gmail.com> | 2018-01-22 20:44:33 +0000 |
---|---|---|
committer | Marshall Clow <mclow.lists@gmail.com> | 2018-01-22 20:44:33 +0000 |
commit | 1b9a4ffd6bb2622360e6bae10bbcce7348186e94 (patch) | |
tree | 5a14c13574c3b1180031bd6aefdc1427cf9446a8 /libcxx/test/std/algorithms/alg.nonmodifying/alg.foreach/test.pass.cpp | |
parent | d7d991e881fb3f74325a13cc80cc5467eb43af65 (diff) | |
download | bcm5719-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.nonmodifying/alg.foreach/test.pass.cpp')
-rw-r--r-- | libcxx/test/std/algorithms/alg.nonmodifying/alg.foreach/test.pass.cpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/libcxx/test/std/algorithms/alg.nonmodifying/alg.foreach/test.pass.cpp b/libcxx/test/std/algorithms/alg.nonmodifying/alg.foreach/test.pass.cpp index d6fdd18968d..a334c609333 100644 --- a/libcxx/test/std/algorithms/alg.nonmodifying/alg.foreach/test.pass.cpp +++ b/libcxx/test/std/algorithms/alg.nonmodifying/alg.foreach/test.pass.cpp @@ -11,14 +11,26 @@ // template<InputIterator Iter, Callable<auto, Iter::reference> Function> // requires CopyConstructible<Function> -// Function +// constexpr Function // constexpr after C++17 // for_each(Iter first, Iter last, Function f); #include <algorithm> #include <cassert> +#include "test_macros.h" #include "test_iterators.h" +#if TEST_STD_VER > 17 +TEST_CONSTEXPR bool test_constexpr() { + int ia[] = {1, 3, 6, 7}; + int expected[] = {3, 5, 8, 9}; + + std::for_each(std::begin(ia), std::end(ia), [](int &a) { a += 2; }); + return std::equal(std::begin(ia), std::end(ia), std::begin(expected)) + ; + } +#endif + struct for_each_test { for_each_test(int c) : count(c) {} @@ -36,4 +48,8 @@ int main() assert(f.count == s); for (unsigned i = 0; i < s; ++i) assert(ia[i] == static_cast<int>(i+1)); + +#if TEST_STD_VER > 17 + static_assert(test_constexpr()); +#endif } |