diff options
author | Marshall Clow <mclow.lists@gmail.com> | 2018-01-15 19:26:05 +0000 |
---|---|---|
committer | Marshall Clow <mclow.lists@gmail.com> | 2018-01-15 19:26:05 +0000 |
commit | 8694428e365648723f5519af0a6818eb24ecb990 (patch) | |
tree | 633b962ba16be5e53395023779e649ab6bcc090c /libcxx/test/std/algorithms/alg.nonmodifying/alg.find.end/find_end.pass.cpp | |
parent | b60f1b6d3debbbdbcd057d763fbef7e2492718a3 (diff) | |
download | bcm5719-llvm-8694428e365648723f5519af0a6818eb24ecb990.tar.gz bcm5719-llvm-8694428e365648723f5519af0a6818eb24ecb990.zip |
More P0202 constexpr-ifying. All the find_XXX algorithms in this commit.
llvm-svn: 322504
Diffstat (limited to 'libcxx/test/std/algorithms/alg.nonmodifying/alg.find.end/find_end.pass.cpp')
-rw-r--r-- | libcxx/test/std/algorithms/alg.nonmodifying/alg.find.end/find_end.pass.cpp | 26 |
1 files changed, 25 insertions, 1 deletions
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<ForwardIterator Iter1, ForwardIterator Iter2> // requires HasEqualTo<Iter1::value_type, Iter2::value_type> -// Iter1 +// constexpr Iter1 // constexpr after C++17 // find_end(Iter1 first1, Iter1 last1, Iter2 first2, Iter2 last2); #include <algorithm> #include <cassert> +#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<int*> FI; + typedef bidirectional_iterator<int*> BI; + typedef random_access_iterator<int*> 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 <class Iter1, class Iter2> void test() @@ -54,4 +74,8 @@ int main() test<random_access_iterator<const int*>, forward_iterator<const int*> >(); test<random_access_iterator<const int*>, bidirectional_iterator<const int*> >(); test<random_access_iterator<const int*>, random_access_iterator<const int*> >(); + +#if TEST_STD_VER > 17 + static_assert(test_constexpr()); +#endif } |