aboutsummaryrefslogtreecommitdiff
path: root/test/std/algorithms/alg.nonmodifying/alg.find.first.of/find_first_of_pred.pass.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/std/algorithms/alg.nonmodifying/alg.find.first.of/find_first_of_pred.pass.cpp')
-rw-r--r--test/std/algorithms/alg.nonmodifying/alg.find.first.of/find_first_of_pred.pass.cpp26
1 files changed, 25 insertions, 1 deletions
diff --git a/test/std/algorithms/alg.nonmodifying/alg.find.first.of/find_first_of_pred.pass.cpp b/test/std/algorithms/alg.nonmodifying/alg.find.first.of/find_first_of_pred.pass.cpp
index d1d954ca0cae..f6f1725d6fa7 100644
--- a/test/std/algorithms/alg.nonmodifying/alg.find.first.of/find_first_of_pred.pass.cpp
+++ b/test/std/algorithms/alg.nonmodifying/alg.find.first.of/find_first_of_pred.pass.cpp
@@ -12,15 +12,35 @@
// template<InputIterator Iter1, ForwardIterator Iter2,
// Predicate<auto, Iter1::value_type, Iter2::value_type> Pred>
// requires CopyConstructible<Pred>
-// Iter1
+// constexpr Iter1 // constexpr after C++17
// find_first_of(Iter1 first1, Iter1 last1, Iter2 first2, Iter2 last2, Pred pred);
#include <algorithm>
#include <functional>
#include <cassert>
+#include "test_macros.h"
#include "test_iterators.h"
+#if TEST_STD_VER > 17
+constexpr bool test_constexpr() {
+ int ia[] = {1, 2, 3};
+ int ib[] = {7, 8, 9};
+ int ic[] = {0, 1, 2, 3, 4, 5, 0, 1, 2, 3};
+ typedef forward_iterator<int*> FI;
+ typedef bidirectional_iterator<int*> BI;
+ typedef random_access_iterator<int*> RI;
+ std::equal_to<int> eq{};
+ return (std::find_first_of(FI(std::begin(ic)), FI(std::end(ic)), FI(std::begin(ia)), FI(std::end(ia)), eq) == FI(ic+1))
+ && (std::find_first_of(FI(std::begin(ic)), FI(std::end(ic)), FI(std::begin(ib)), FI(std::end(ib)), eq) == FI(std::end(ic)))
+ && (std::find_first_of(BI(std::begin(ic)), BI(std::end(ic)), BI(std::begin(ia)), BI(std::end(ia)), eq) == BI(ic+1))
+ && (std::find_first_of(BI(std::begin(ic)), BI(std::end(ic)), BI(std::begin(ib)), BI(std::end(ib)), eq) == BI(std::end(ic)))
+ && (std::find_first_of(RI(std::begin(ic)), RI(std::end(ic)), RI(std::begin(ia)), RI(std::end(ia)), eq) == RI(ic+1))
+ && (std::find_first_of(RI(std::begin(ic)), RI(std::end(ic)), RI(std::begin(ib)), RI(std::end(ib)), eq) == RI(std::end(ic)))
+ ;
+ }
+#endif
+
int main()
{
int ia[] = {0, 1, 2, 3, 0, 1, 2, 3};
@@ -52,4 +72,8 @@ int main()
forward_iterator<const int*>(ic+1),
std::equal_to<int>()) ==
input_iterator<const int*>(ia));
+
+#if TEST_STD_VER > 17
+ static_assert(test_constexpr());
+#endif
}