xref: /llvm-project/libcxx/test/std/concepts/concepts.callable/concept.relation/relation.compile.pass.cpp (revision 96dbdd753a1f8bfe0d03f13de484fa18c8bca8db)
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 static_assert(std::relation<bool(int, int), int, int>);
18 static_assert(std::relation<bool(int, int), double, double>);
19 static_assert(std::relation<bool(int, double), double, double>);
20 
21 static_assert(!std::relation<bool(), int, double>);
22 static_assert(!std::relation<bool(int), int, double>);
23 static_assert(!std::relation<bool(double), int, double>);
24 static_assert(!std::relation<bool(double, double*), double, double*>);
25 static_assert(!std::relation<bool(int&, int&), double&, double&>);
26 
27 struct S1 {};
28 static_assert(std::relation<bool (S1::*)(S1*), S1*, S1*>);
29 static_assert(std::relation<bool (S1::*)(S1&), S1&, S1&>);
30 
31 struct S2 {};
32 
33 struct P1 {
34   bool operator()(S1, S1) const;
35 };
36 static_assert(std::relation<P1, S1, S1>);
37 
38 struct P2 {
39   bool operator()(S1, S1) const;
40   bool operator()(S1, S2) const;
41 };
42 static_assert(!std::relation<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::relation<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::relation<P4, S1, S2>);
58