Jens Maurer

N3272: Follow-up on override control

The paper N3206 "Override control: Eliminating Attributes" was voted into the C++ Working Paper in Batavia (see also FCD National Body comments US 44 and CA 3).

This paper implements the current consensus of removing the "hiding" feature and the "explicit" annotation on classes. It is based on the paper N3234 "Remove explicit from class-head" by Ville Voutilainen.

This paper also addresses core issue 1063.

This paper assumes that the proposed resolution of core issue 1201 has been applied.

Thanks to Mark Hall and Ville Voutilainen for their input.

Change in 8.4.1 dcl.fct.def.general paragraph 1:
      attribute-specifier-seqopt decl-specifier-seqopt declarator virt-specifier-seqopt function-body
... The optional attribute-specifier-seq in a function-definition appertains to the function. A virt-specifier-seq can be part of a function-definition only if it is a member-declaration (9.2 class.mem).
Change in 9 class paragraph 1:
       class-key attribute-specifier-seqopt class-head-name class-virt-specifier-seqopt base-clauseopt
       class-key attribute-specifier-seqopt base-clauseopt
A class-virt-specifier-seq shall contain at most one of each class-virt-specifier. A class-specifier whose class-head omits the class-head-name defines an unnamed class. [ Note: An unnamed class thus can't be final or explicit. -- end note ]
Change in 9.2 class.mem:
    declarator virt-specifier-seqopt pure-specifieropt
    declarator virt-specifier-seqopt brace-or-equal-initializeropt
    identifieropt attribute-specifier-seqopt virt-specifier-seqopt : constant-expression
Change in 9.2 class.mem paragraph 9:
A virt-specifier-seq shall contain at most one of each virt-specifier. The virt-specifiers override and final A virt-specifier-seq shall only appear only in the declaration of a virtual member function (10.3 class.virtual).
Remove 9.2 class.mem paragraph 10:
If a class member is marked new and its name does not hide (3.3.10 basic.scope.hiding, 10.2 class.member.lookup) a class member name in a base class the program is ill-formed.
Remove 10 class.derived paragraph 9:
In a class definition marked with the class-virt-specifier explicit ... [ Note: ... ] [ Example: ... ]
Change in 10.3 class.virtual paragraph 5:
If a virtual function is marked with the virt-specifier override and does not override a member function of a base class, the program is ill-formed. [ Example:
   struct B {
     virtual void f(int);
   struct D : B {
     void f(long) override;     // error: wrong signature overriding B::f
     void f(int) override;      // OK
-- end example ]