File: predefined.cc

package info (click to toggle)
c%2B%2B-annotations 11.5.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 11,244 kB
  • sloc: cpp: 21,698; makefile: 1,505; ansic: 165; sh: 121; perl: 90
file content (50 lines) | stat: -rw-r--r-- 800 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <string>
#include <concepts>

template <typename LHS, typename RHS>
concept CommonWith = std::common_with<LHS, RHS>;

template <typename T1, typename T2>
    requires CommonWith<T1, T2>
void fun2(T1 &&t1, T2 &&t2)
{}


template <typename LHS, typename RHS>
concept CommonRef = std::common_reference_with<LHS, RHS>;

template <typename T1, typename T2>
    requires CommonRef<T1, T2>
void fun(T1 &&t1, T2 &&t2)
{}

struct B
{};

struct D1: public B
{
};

struct D2: public B
{
};

int main()
{
    fun(4, 'a');
    fun(4.5, 'a');

    D1 d1;
    B b;

    fun(b, d1);   // OK
    fun(d1, b);   // OK
    fun(B{}, d1);   // OK
    fun(d1, B{});   // OK
    fun(b, D1{});   // OK
    fun(D1{}, b);   // OK
    fun(B{}, D1{});   // OK
    fun(D1{}, B{});   // OK

    fun2(B{}, D2{});   // OK
}