• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
f()17 void 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(a, a + 4, 0, &S::compare); // expected-error@*:* {{The comparator has to be callable}}
28   (void) std::minmax({S{1}}, &S::compare); // expected-error@*:* {{The comparator has to be callable}}
29   (void) std::minmax_element(a, a + 4, &S::compare); // expected-error@*:* {{The comparator has to be callable}}
30 }
31