From 8694428e365648723f5519af0a6818eb24ecb990 Mon Sep 17 00:00:00 2001 From: Marshall Clow Date: Mon, 15 Jan 2018 19:26:05 +0000 Subject: More P0202 constexpr-ifying. All the find_XXX algorithms in this commit. llvm-svn: 322504 --- .../alg.find.end/find_end.pass.cpp | 26 +++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'libcxx/test/std/algorithms/alg.nonmodifying/alg.find.end/find_end.pass.cpp') diff --git a/libcxx/test/std/algorithms/alg.nonmodifying/alg.find.end/find_end.pass.cpp b/libcxx/test/std/algorithms/alg.nonmodifying/alg.find.end/find_end.pass.cpp index e95162b4ad7..bc5d50cd5dd 100644 --- a/libcxx/test/std/algorithms/alg.nonmodifying/alg.find.end/find_end.pass.cpp +++ b/libcxx/test/std/algorithms/alg.nonmodifying/alg.find.end/find_end.pass.cpp @@ -11,14 +11,34 @@ // template // requires HasEqualTo -// Iter1 +// constexpr Iter1 // constexpr after C++17 // find_end(Iter1 first1, Iter1 last1, Iter2 first2, Iter2 last2); #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}; + int ib[] = {4, 5, 6}; + int ic[] = {0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 0, 1, 2, 3, 0, 1, 2, 0, 1, 0}; + typedef forward_iterator FI; + typedef bidirectional_iterator BI; + typedef random_access_iterator RI; + + return (std::find_end(FI(std::begin(ic)), FI(std::end(ic)), FI(std::begin(ia)), FI(std::end(ia))) == FI(ic+15)) + && (std::find_end(FI(std::begin(ic)), FI(std::end(ic)), FI(std::begin(ib)), FI(std::end(ib))) == FI(std::end(ic))) + && (std::find_end(BI(std::begin(ic)), BI(std::end(ic)), BI(std::begin(ia)), BI(std::end(ia))) == BI(ic+15)) + && (std::find_end(BI(std::begin(ic)), BI(std::end(ic)), BI(std::begin(ib)), BI(std::end(ib))) == BI(std::end(ic))) + && (std::find_end(RI(std::begin(ic)), RI(std::end(ic)), RI(std::begin(ia)), RI(std::end(ia))) == RI(ic+15)) + && (std::find_end(RI(std::begin(ic)), RI(std::end(ic)), RI(std::begin(ib)), RI(std::end(ib))) == RI(std::end(ic))) + ; + } +#endif + template void test() @@ -54,4 +74,8 @@ int main() test, forward_iterator >(); test, bidirectional_iterator >(); test, random_access_iterator >(); + +#if TEST_STD_VER > 17 + static_assert(test_constexpr()); +#endif } -- cgit v1.2.3