64 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8 9// UNSUPPORTED: c++03, c++11, c++14, c++1710 11// template<class F, class... Args>12// concept relation;13 14#include <concepts>15 16struct S1 {};17struct S2 {};18 19struct 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 off27template<class F, class T, class U>28requires std::predicate<F, T, T> && std::predicate<F, T, U> &&29 std::predicate<F, U, T> && std::predicate<F, U, U>30constexpr bool check_relation_subsumes_predicate() {31 return false;32}33 34template<class F, class T, class U>35requires std::relation<F, T, U> && true36constexpr bool check_relation_subsumes_predicate() {37 return true;38}39// clang-format on40 41static_assert(42 check_relation_subsumes_predicate<int (*)(int, double), int, int>());43static_assert(44 check_relation_subsumes_predicate<int (*)(int, double), int, double>());45static_assert(check_relation_subsumes_predicate<R, S1, S1>());46static_assert(check_relation_subsumes_predicate<R, S1, S2>());47 48// clang-format off49template<class F, class T, class U>50requires std::relation<F, T, T> && std::relation<F, U, U>51constexpr bool check_relation_subsumes_itself() {52 return false;53}54 55template<class F, class T, class U>56requires std::relation<F, T, U>57constexpr bool check_relation_subsumes_itself() {58 return true;59}60// clang-format on61 62static_assert(check_relation_subsumes_itself<int (*)(int, double), int, int>());63static_assert(check_relation_subsumes_itself<R, S1, S1>());64