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
10
11// <algorithm>
12
13// check that the classical algorithms with non-callable comparators fail
14
15#include <algorithm>
16
17void f() {
18 struct S {
19 int i;
20
21 S(int i_) : i(i_) {}
22
23 bool compare(const S&) const;
24 };
25
26 S a[] = {1, 2, 3, 4};
27 (void) std::lower_bound(first: a, last: a + 4, val: 0, comp: &S::compare); // expected-error@*:* {{The comparator has to be callable}}
28 (void) std::minmax(l: {S{1}}, comp: &S::compare); // expected-error@*:* {{The comparator has to be callable}}
29 (void) std::minmax_element(first: a, last: a + 4, comp: &S::compare); // expected-error@*:* {{The comparator has to be callable}}
30}
31

source code of libcxx/test/libcxx/algorithms/callable.verify.cpp