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 | // template<class F, class... Args> |
12 | // concept strict_weak_order; |
13 | |
14 | #include <concepts> |
15 | |
16 | static_assert(std::strict_weak_order<bool(int, int), int, int>); |
17 | static_assert(std::strict_weak_order<bool(int, int), double, double>); |
18 | static_assert(std::strict_weak_order<bool(int, double), double, double>); |
19 | |
20 | static_assert(!std::strict_weak_order<bool (*)(), int, double>); |
21 | static_assert(!std::strict_weak_order<bool (*)(int), int, double>); |
22 | static_assert(!std::strict_weak_order<bool (*)(double), int, double>); |
23 | |
24 | static_assert(!std::strict_weak_order<bool(double, double*), double, double*>); |
25 | static_assert(!std::strict_weak_order<bool(int&, int&), double&, double&>); |
26 | |
27 | struct S1 {}; |
28 | static_assert(std::strict_weak_order<bool (S1::*)(S1*), S1*, S1*>); |
29 | static_assert(std::strict_weak_order<bool (S1::*)(S1&), S1&, S1&>); |
30 | |
31 | struct S2 {}; |
32 | |
33 | struct P1 { |
34 | bool operator()(S1, S1) const; |
35 | }; |
36 | static_assert(std::strict_weak_order<P1, S1, S1>); |
37 | |
38 | struct P2 { |
39 | bool operator()(S1, S1) const; |
40 | bool operator()(S1, S2) const; |
41 | }; |
42 | static_assert(!std::strict_weak_order<P2, S1, S2>); |
43 | |
44 | struct P3 { |
45 | bool operator()(S1, S1) const; |
46 | bool operator()(S1, S2) const; |
47 | bool operator()(S2, S1) const; |
48 | }; |
49 | static_assert(!std::strict_weak_order<P3, S1, S2>); |
50 | |
51 | struct P4 { |
52 | bool operator()(S1, S1) const; |
53 | bool operator()(S1, S2) const; |
54 | bool operator()(S2, S1) const; |
55 | bool operator()(S2, S2) const; |
56 | }; |
57 | static_assert(std::strict_weak_order<P4, S1, S2>); |
58 | |