summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/algorithms/alg.nonmodifying/alg.adjacent.find/adjacent_find.pass.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libcxx/test/std/algorithms/alg.nonmodifying/alg.adjacent.find/adjacent_find.pass.cpp')
-rw-r--r--libcxx/test/std/algorithms/alg.nonmodifying/alg.adjacent.find/adjacent_find.pass.cpp18
1 files changed, 17 insertions, 1 deletions
diff --git a/libcxx/test/std/algorithms/alg.nonmodifying/alg.adjacent.find/adjacent_find.pass.cpp b/libcxx/test/std/algorithms/alg.nonmodifying/alg.adjacent.find/adjacent_find.pass.cpp
index ee030925d55..8de06ec7b4b 100644
--- a/libcxx/test/std/algorithms/alg.nonmodifying/alg.adjacent.find/adjacent_find.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.nonmodifying/alg.adjacent.find/adjacent_find.pass.cpp
@@ -11,14 +11,26 @@
// template<ForwardIterator Iter>
// requires EqualityComparable<Iter::value_type>
-// Iter
+// constexpr Iter // constexpr after C++17
// adjacent_find(Iter first, Iter last);
#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, 2, 0, 1, 2, 3};
+ int ib[] = {0, 1, 2, 7, 0, 1, 2, 3};
+
+ return (std::adjacent_find(std::begin(ia), std::end(ia)) == ia+2)
+ && (std::adjacent_find(std::begin(ib), std::end(ib)) == std::end(ib))
+ ;
+ }
+#endif
+
int main()
{
int ia[] = {0, 1, 2, 2, 0, 1, 2, 3};
@@ -32,4 +44,8 @@ int main()
assert(std::adjacent_find(forward_iterator<const int*>(ia+3),
forward_iterator<const int*>(ia + sa)) ==
forward_iterator<const int*>(ia+sa));
+
+#if TEST_STD_VER > 17
+ static_assert(test_constexpr());
+#endif
}
OpenPOWER on IntegriCloud