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 <class InputIterator, class Predicate>
12 // constexpr bool // constexpr after C++17
13 // any_of(InputIterator first, InputIterator last, Predicate pred);
18 #include "test_macros.h"
19 #include "test_iterators.h"
23 TEST_CONSTEXPR
bool operator()(const int& i
) const
30 TEST_CONSTEXPR
bool test_constexpr() {
31 int ia
[] = {2, 4, 6, 8};
32 int ib
[] = {1, 3, 5, 7};
33 return std::any_of(std::begin(ia
), std::end(ia
), test1())
34 && !std::any_of(std::begin(ib
), std::end(ib
), test1())
42 int ia
[] = {2, 4, 6, 8};
43 const unsigned sa
= sizeof(ia
)/sizeof(ia
[0]);
44 assert(std::any_of(cpp17_input_iterator
<const int*>(ia
),
45 cpp17_input_iterator
<const int*>(ia
+ sa
), test1()) == true);
46 assert(std::any_of(cpp17_input_iterator
<const int*>(ia
),
47 cpp17_input_iterator
<const int*>(ia
), test1()) == false);
50 const int ia
[] = {2, 4, 5, 8};
51 const unsigned sa
= sizeof(ia
)/sizeof(ia
[0]);
52 assert(std::any_of(cpp17_input_iterator
<const int*>(ia
),
53 cpp17_input_iterator
<const int*>(ia
+ sa
), test1()) == true);
54 assert(std::any_of(cpp17_input_iterator
<const int*>(ia
),
55 cpp17_input_iterator
<const int*>(ia
), test1()) == false);
58 const int ia
[] = {1, 3, 5, 7};
59 const unsigned sa
= sizeof(ia
)/sizeof(ia
[0]);
60 assert(std::any_of(cpp17_input_iterator
<const int*>(ia
),
61 cpp17_input_iterator
<const int*>(ia
+ sa
), test1()) == false);
62 assert(std::any_of(cpp17_input_iterator
<const int*>(ia
),
63 cpp17_input_iterator
<const int*>(ia
), test1()) == false);
67 static_assert(test_constexpr());