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 // UNSUPPORTED: libcpp-no-concepts
11 
12 // template<class F, class... Args>
13 // concept relation;
14 
15 #include <concepts>
16 
17 struct S1 {};
18 struct S2 {};
19 
20 struct R {
21   bool operator()(S1, S1) const;
22   bool operator()(S1, S2) const;
23   bool operator()(S2, S1) const;
24   bool operator()(S2, S2) const;
25 };
26 
27 // clang-format off
28 template<class F, class T, class U>
29 requires std::predicate<F, T, T> && std::predicate<F, T, U> &&
30          std::predicate<F, U, T> && std::predicate<F, U, U>
31 constexpr bool check_relation_subsumes_predicate() {
32   return false;
33 }
34 
35 template<class F, class T, class U>
36 requires std::relation<F, T, U> && true
37 constexpr bool check_relation_subsumes_predicate() {
38   return true;
39 }
40 // clang-format on
41 
42 static_assert(
43     check_relation_subsumes_predicate<int (*)(int, double), int, int>());
44 static_assert(
45     check_relation_subsumes_predicate<int (*)(int, double), int, double>());
46 static_assert(check_relation_subsumes_predicate<R, S1, S1>());
47 static_assert(check_relation_subsumes_predicate<R, S1, S2>());
48 
49 // clang-format off
50 template<class F, class T, class U>
51 requires std::relation<F, T, T> && std::relation<F, U, U>
52 constexpr bool check_relation_subsumes_itself() {
53   return false;
54 }
55 
56 template<class F, class T, class U>
57 requires std::relation<F, T, U>
58 constexpr bool check_relation_subsumes_itself() {
59   return true;
60 }
61 // clang-format on
62 
63 static_assert(check_relation_subsumes_itself<int (*)(int, double), int, int>());
64 static_assert(check_relation_subsumes_itself<R, S1, S1>());
65