| 1 |
#include <string> |
| 2 |
#include <concepts> |
| 3 |
|
| 4 |
template <typename LHS, typename RHS> |
| 5 |
concept CommonWith = std::common_with<LHS, RHS>; |
| 6 |
|
| 7 |
template <typename T1, typename T2> |
| 8 |
requires CommonWith<T1, T2> |
| 9 |
void fun2(T1 &&t1, T2 &&t2) |
| 10 |
{} |
| 11 |
|
| 12 |
|
| 13 |
//commonref |
| 14 |
template <typename LHS, typename RHS> |
| 15 |
concept CommonRef = std::common_reference_with<LHS, RHS>; |
| 16 |
|
| 17 |
template <typename T1, typename T2> |
| 18 |
requires CommonRef<T1, T2> |
| 19 |
void fun(T1 &&t1, T2 &&t2) |
| 20 |
{} |
| 21 |
|
| 22 |
struct B |
| 23 |
{}; |
| 24 |
|
| 25 |
struct D1: public B |
| 26 |
{ |
| 27 |
}; |
| 28 |
|
| 29 |
int main() |
| 30 |
{ |
| 31 |
fun(4, 'a'); |
| 32 |
fun(4.5, 'a'); |
| 33 |
|
| 34 |
D1 d1; |
| 35 |
B b; |
| 36 |
|
| 37 |
fun(b, d1); // objects, rvalue refs: |
| 38 |
fun(D1{}, B{}); // all OK |
| 39 |
} |
| 40 |
//= |