-
Notifications
You must be signed in to change notification settings - Fork 7
Description
Following discussions about CWG2555
Consider
struct K {
void f(this K); //#1
void f(); //#2
};
Here, exactly one (#2
) function has an implicit object parameter and no ref qualifier, and after removing references, both have the same type (K)
- per https://eel.is/c++draft/over.match.funcs#general-4 - although whether this rule applies could be clearer.
So #1 and #2 correspond, even though they do have different object parameter type (K
and K&
respectively)
All compilers reject that code.
However, consider a very similar example
struct OK {
void f(this OK);
void f() &;
};
Here, no overload has "an implicit object parameter and no ref qualifier" so references are not stripped, we compare K
and K&
, which are not the same type, the parameter do not correspond and we can declare a distinct overload.
What makes us want a different outcome in both scenarios, when the model is that the lack of &
does not implies by value?