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
|
#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)
{}
//commonref
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
{
};
int main()
{
fun(4, 'a');
fun(4.5, 'a');
D1 d1;
B b;
fun(b, d1); // objects, rvalue refs:
fun(D1{}, B{}); // all OK
}
//=
|