Created on 2021-06-16.00:00:00 last changed 27 months ago
Proposed resolution, August, 2021:
Add the following as a new paragraph preceding 11.7.3 [class.virtual] paragraph 7:
The ref-qualifier, or lack thereof, of an overriding function shall be the same as that of the overridden function.
The return type of an overriding function shall be either identical to the return type of the overridden function or covariant...
Notes from the August, 2021 teleconference:
CWG preferred the second option.
[Accepted as a DR at the October, 2021 meeting.]
According to 11.7.3 [class.virtual] paragraph 2,
If a virtual member function F is declared in a class B, and, in a class D derived (directly or indirectly) from B, a declaration of a member function G corresponds (6.4.1 [basic.scope.scope]) to a declaration of F, ignoring trailing requires-clauses, then G overrides105 F.
This is different from C++20, where G was considered to hide, rather than to override, F if the ref-qualifiers of the declarations are different. This unintentional change could be addressed in one of two ways. To restore the C++20 behavior, the cited paragraph could be amended to:
...a declaration of a member function G corresponds (6.4.1 [basic.scope.scope]) to a declaration of F, ignoring trailing requires-clauses, and has the same ref-qualifier (if any), then G overrides105 F.
Alternatively, such a situation could be regarded as an ill-formed attempt to override the base class function, which could be specified by adding the following as a new paragraph preceding 11.7.3 [class.virtual] paragraph 7:
The ref-qualifier, or lack thereof, of an overriding function shall be the same as that of the overridden function.
The return type of an overriding function shall be either identical to the return type of the overridden function or covariant...
History | |||
---|---|---|---|
Date | User | Action | Args |
2022-08-19 07:54:33 | admin | set | status: drwp -> cd6 |
2022-02-15 00:00:00 | admin | set | status: dr -> drwp |
2021-11-15 00:00:00 | admin | set | messages: + msg6579 |
2021-11-15 00:00:00 | admin | set | messages: + msg6578 |
2021-06-16 00:00:00 | admin | create |