1 //===----------------------------------------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
11 // template<ForwardIterator Iter>
12 // requires EqualityComparable<Iter::value_type>
13 // constexpr Iter // constexpr after C++17
14 // adjacent_find(Iter first, Iter last);
19 #include "test_macros.h"
20 #include "test_iterators.h"
23 TEST_CONSTEXPR
bool test_constexpr() {
24 int ia
[] = {0, 1, 2, 2, 0, 1, 2, 3};
25 int ib
[] = {0, 1, 2, 7, 0, 1, 2, 3};
27 return (std::adjacent_find(std::begin(ia
), std::end(ia
)) == ia
+2)
28 && (std::adjacent_find(std::begin(ib
), std::end(ib
)) == std::end(ib
))
35 int ia
[] = {0, 1, 2, 2, 0, 1, 2, 3};
36 const unsigned sa
= sizeof(ia
)/sizeof(ia
[0]);
37 assert(std::adjacent_find(forward_iterator
<const int*>(ia
),
38 forward_iterator
<const int*>(ia
+ sa
)) ==
39 forward_iterator
<const int*>(ia
+2));
40 assert(std::adjacent_find(forward_iterator
<const int*>(ia
),
41 forward_iterator
<const int*>(ia
)) ==
42 forward_iterator
<const int*>(ia
));
43 assert(std::adjacent_find(forward_iterator
<const int*>(ia
+3),
44 forward_iterator
<const int*>(ia
+ sa
)) ==
45 forward_iterator
<const int*>(ia
+sa
));
48 static_assert(test_constexpr());