|
| 1 | +//===----------------------------------------------------------------------===// |
| 2 | +// |
| 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 |
| 6 | +// |
| 7 | +//===----------------------------------------------------------------------===// |
| 8 | + |
| 9 | +// UNSUPPORTED: c++03, c++11, c++14, c++17 |
| 10 | + |
| 11 | +// <algorithm> |
| 12 | +// |
| 13 | +// Algorithms that take predicates should support predicates that return a non-boolean value as long as the |
| 14 | +// returned type is implicitly convertible to bool. |
| 15 | + |
| 16 | +#include <algorithm> |
| 17 | + |
| 18 | +#include <initializer_list> |
| 19 | + |
| 20 | +#include "boolean_testable.h" |
| 21 | + |
| 22 | +using Value = StrictComparable<int>; |
| 23 | +using Iterator = StrictBooleanIterator<Value*>; |
| 24 | +auto pred1 = StrictUnaryPredicate; |
| 25 | +auto pred2 = StrictBinaryPredicate; |
| 26 | + |
| 27 | +void f(Iterator it, Iterator out, std::size_t n, Value const& val, std::initializer_list<Value> ilist) { |
| 28 | + (void)std::any_of(it, it, pred1); |
| 29 | + (void)std::all_of(it, it, pred1); |
| 30 | + (void)std::none_of(it, it, pred1); |
| 31 | + (void)std::find_if(it, it, pred1); |
| 32 | + (void)std::find_if_not(it, it, pred1); |
| 33 | + (void)std::find_first_of(it, it, it, it); |
| 34 | + (void)std::find_first_of(it, it, it, it, pred2); |
| 35 | + (void)std::adjacent_find(it, it); |
| 36 | + (void)std::adjacent_find(it, it, pred2); |
| 37 | + (void)std::mismatch(it, it, it, it); |
| 38 | + (void)std::mismatch(it, it, it, it, pred2); |
| 39 | + (void)std::mismatch(it, it, it); |
| 40 | + (void)std::mismatch(it, it, it); |
| 41 | + (void)std::mismatch(it, it, it, pred2); |
| 42 | + (void)std::equal(it, it, it, it); |
| 43 | + (void)std::equal(it, it, it, it, pred2); |
| 44 | + (void)std::equal(it, it, it); |
| 45 | + (void)std::equal(it, it, it, pred2); |
| 46 | + (void)std::lexicographical_compare(it, it, it, it); |
| 47 | + (void)std::lexicographical_compare(it, it, it, it, pred2); |
| 48 | + (void)std::partition_point(it, it, pred1); |
| 49 | + (void)std::lower_bound(it, it, val); |
| 50 | + (void)std::lower_bound(it, it, val, pred2); |
| 51 | + (void)std::upper_bound(it, it, val); |
| 52 | + (void)std::upper_bound(it, it, val, pred2); |
| 53 | + (void)std::equal_range(it, it, val); |
| 54 | + (void)std::equal_range(it, it, val, pred2); |
| 55 | + (void)std::binary_search(it, it, val); |
| 56 | + (void)std::binary_search(it, it, val, pred2); |
| 57 | + (void)std::min(val, val); |
| 58 | + (void)std::min(val, val, pred2); |
| 59 | + (void)std::min(ilist); |
| 60 | + (void)std::min(ilist, pred2); |
| 61 | + (void)std::max(val, val); |
| 62 | + (void)std::max(val, val, pred2); |
| 63 | + (void)std::max(ilist); |
| 64 | + (void)std::max(ilist, pred2); |
| 65 | + (void)std::minmax(val, val); |
| 66 | + (void)std::minmax(val, val, pred2); |
| 67 | + (void)std::minmax(ilist); |
| 68 | + (void)std::minmax(ilist, pred2); |
| 69 | + (void)std::min_element(it, it); |
| 70 | + (void)std::min_element(it, it, pred2); |
| 71 | + (void)std::max_element(it, it); |
| 72 | + (void)std::max_element(it, it, pred2); |
| 73 | + (void)std::minmax_element(it, it); |
| 74 | + (void)std::minmax_element(it, it, pred2); |
| 75 | + (void)std::count_if(it, it, pred1); |
| 76 | + (void)std::search(it, it, it ,it); |
| 77 | + (void)std::search(it, it, it ,it, pred2); |
| 78 | + (void)std::search_n(it, it, n, val); |
| 79 | + (void)std::search_n(it, it, n, val, pred2); |
| 80 | + (void)std::is_partitioned(it ,it, pred1); |
| 81 | + (void)std::is_sorted(it ,it); |
| 82 | + (void)std::is_sorted(it ,it, pred2); |
| 83 | + (void)std::is_sorted_until(it ,it); |
| 84 | + (void)std::is_sorted_until(it ,it, pred2); |
| 85 | + (void)std::is_heap(it, it); |
| 86 | + (void)std::is_heap(it, it, pred2); |
| 87 | + (void)std::is_heap_until(it, it); |
| 88 | + (void)std::is_heap_until(it, it, pred2); |
| 89 | + (void)std::clamp(val, val, val); |
| 90 | + (void)std::clamp(val, val, val, pred2); |
| 91 | + (void)std::is_permutation(it, it, it, it); |
| 92 | + (void)std::is_permutation(it, it, it, it, pred2); |
| 93 | + (void)std::copy_if(it, it, out, pred1); |
| 94 | + (void)std::remove_copy_if(it, it, out, pred1); |
| 95 | + (void)std::remove_copy(it, it, out, val); |
| 96 | + (void)std::replace(it, it, val, val); |
| 97 | + (void)std::replace_if(it, it, pred1, val); |
| 98 | + (void)std::replace_copy_if(it, it, out, pred1, val); |
| 99 | + (void)std::replace_copy(it, it, out, val, val); |
| 100 | + (void)std::unique_copy(it, it, out, pred2); |
| 101 | + (void)std::partition_copy(it, it, out, out, pred1); |
| 102 | + (void)std::partial_sort_copy(it, it, it, it, pred2); |
| 103 | + (void)std::merge(it, it, it, it, out); |
| 104 | + (void)std::merge(it, it, it, it, out, pred2); |
| 105 | + (void)std::set_difference(it, it, it, it, out, pred2); |
| 106 | + (void)std::set_intersection(it, it, it, it, out, pred2); |
| 107 | + (void)std::set_symmetric_difference(it, it, it, it, out, pred2); |
| 108 | + (void)std::set_union(it, it, it, it, out, pred2); |
| 109 | + (void)std::remove_if(it, it, pred1); |
| 110 | + (void)std::remove(it, it, val); |
| 111 | + (void)std::unique(it, it, pred2); |
| 112 | + (void)std::partition(it, it, pred1); |
| 113 | + (void)std::stable_partition(it, it, pred1); |
| 114 | + (void)std::sort(it, it); |
| 115 | + (void)std::sort(it, it, pred2); |
| 116 | + (void)std::stable_sort(it, it); |
| 117 | + (void)std::stable_sort(it, it, pred2); |
| 118 | + (void)std::partial_sort(it, it, it); |
| 119 | + (void)std::partial_sort(it, it, it, pred2); |
| 120 | + (void)std::nth_element(it, it, it); |
| 121 | + (void)std::nth_element(it, it, it, pred2); |
| 122 | + (void)std::inplace_merge(it, it, it); |
| 123 | + (void)std::inplace_merge(it, it, it, pred2); |
| 124 | + (void)std::make_heap(it, it); |
| 125 | + (void)std::make_heap(it, it, pred2); |
| 126 | + (void)std::push_heap(it, it); |
| 127 | + (void)std::push_heap(it, it, pred2); |
| 128 | + (void)std::pop_heap(it, it); |
| 129 | + (void)std::pop_heap(it, it, pred2); |
| 130 | + (void)std::sort_heap(it, it); |
| 131 | + (void)std::sort_heap(it, it, pred2); |
| 132 | + (void)std::prev_permutation(it, it); |
| 133 | + (void)std::prev_permutation(it, it, pred2); |
| 134 | + (void)std::next_permutation(it, it); |
| 135 | + (void)std::next_permutation(it, it, pred2); |
| 136 | +} |
0 commit comments