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 #include <algorithm>
14 
15 #include "test_macros.h"
16 
17 struct A {
18     int i;
19     A(int v) : i(v) {}
20     bool operator<(const A& rhs) const { return i < rhs.i; }
21     static bool isEven(const A& a) { return a.i % 2 == 0; }
22 };
23 
24 void *operator new(size_t, A*) = delete;
25 
26 int main(int, char**)
27 {
28     A a[4] = { 1,2,3,4 };
29     std::sort(a, a+4);
30     std::partition(a, a+4, A::isEven);
31     std::stable_sort(a, a+4);
32     std::stable_partition(a, a+4, A::isEven);
33 
34     return 0;
35 }
36