You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
CWG3103 [basic.scope.scope] Corresponding object members and by-value object parameter #776
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
structOK {
voidf(thisOK);
voidf() &;
};
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?
I don't think we want different outcomes here, and I'd lean towards making the second case ill-formed as well.
If we want any of these to be well-formed, I think we also need to discuss how a using-declaration in a derived class then behaves for these cases, i.e.
changed the title [-][basic.scope.scope] Corresponding object members and by-value object parameter[/-][+]CWG3103 [basic.scope.scope] Corresponding object members and by-value object parameter[/+]on Nov 2, 2025
Activity
cmeerw commentedon Oct 12, 2025
I don't think we want different outcomes here, and I'd lean towards making the second case ill-formed as well.
If we want any of these to be well-formed, I think we also need to discuss how a using-declaration in a derived class then behaves for these cases, i.e.
as there is special treatment for implicit object member functions, but not for explicit object member functions (over.match.funcs/4)
[-][basic.scope.scope] Corresponding object members and by-value object parameter[/-][+]CWG3103 [basic.scope.scope] Corresponding object members and by-value object parameter[/+]jensmaurer commentedon Nov 2, 2025
CWG3103