Description
Consider this example
struct Base{
virtual void show(){} // #1
};
struct Derived: Base{
void show(this Base bptr){} // #2
};
According to [basic.scope.scope] p1, #1
corresponds to #2
as per [basic.scope.scope] p4 if their object parameters should be corresponding. [basic.scope.scope] p3 says that
Two non-static member functions have corresponding object parameters if:
- exactly one is an implicit object member function with no ref-qualifier and the types of their object parameters ([dcl.fct]), after removing top-level references, are the same, or
- their object parameters have the same type.
In this case, #1
and #2
satisfy the first bullet since the type of the implicit object parameter of #1
is Base&
while the type of the explicit object parameter of #2
is Base
, they have the same type after removing the top-level references. Hence, #2
can override#1
? Is it the intention after introducing deducing this?
If an explicit object member function can override an implicit object member function, it seems that the class type of the explicit object parameter must be the base class. Is it also the artificial intent?