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