From 056f15e3c58c1dc471a95b4ec714cc7cd81cbeb0 Mon Sep 17 00:00:00 2001 From: Marshall Clow Date: Mon, 15 Jan 2018 19:40:34 +0000 Subject: More constexpr from P0202. count and count_if. Also fix a comment that Morwenn noted. llvm-svn: 322506 --- .../alg.nonmodifying/alg.count/count.pass.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'libcxx/test/std/algorithms/alg.nonmodifying/alg.count/count.pass.cpp') diff --git a/libcxx/test/std/algorithms/alg.nonmodifying/alg.count/count.pass.cpp b/libcxx/test/std/algorithms/alg.nonmodifying/alg.count/count.pass.cpp index 260e5edece5..bce1095f2ea 100644 --- a/libcxx/test/std/algorithms/alg.nonmodifying/alg.count/count.pass.cpp +++ b/libcxx/test/std/algorithms/alg.nonmodifying/alg.count/count.pass.cpp @@ -11,14 +11,25 @@ // template // requires HasEqualTo -// Iter::difference_type +// constexpr Iter::difference_type // constexpr after C++17 // count(Iter first, Iter last, const T& value); #include #include +#include "test_macros.h" #include "test_iterators.h" +#if TEST_STD_VER > 17 +TEST_CONSTEXPR bool test_constexpr() { + int ia[] = {0, 1, 2, 2, 0, 1, 2, 3}; + int ib[] = {1, 2, 3, 4, 5, 6}; + return (std::count(std::begin(ia), std::end(ia), 2) == 3) + && (std::count(std::begin(ib), std::end(ib), 9) == 0) + ; + } +#endif + int main() { int ia[] = {0, 1, 2, 2, 0, 1, 2, 3}; @@ -29,4 +40,8 @@ int main() input_iterator(ia + sa), 7) == 0); assert(std::count(input_iterator(ia), input_iterator(ia), 2) == 0); + +#if TEST_STD_VER > 17 + static_assert(test_constexpr()); +#endif } -- cgit v1.2.3