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

source code of libcxx/test/std/concepts/concepts.callable/concept.equiv/equivalence_relation.compile.pass.cpp