Jens Maurer
N3272=11-0042
2011年03月23日

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:
function-definition:
 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-head:
 class-key attribute-specifier-seqopt class-head-name class-virt-specifier(削除) -seq (削除ここまで)opt base-clauseopt
 class-key attribute-specifier-seqopt base-clauseopt
...
class-virt-specifier:
 final
 (削除) explicit (削除ここまで)
...
(削除) 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:
member-declarator:
 declarator virt-specifier-seqopt pure-specifieropt
 declarator (削除) virt-specifier-seqopt (削除ここまで) brace-or-equal-initializeropt
 identifieropt attribute-specifier-seqopt (削除) virt-specifier-seqopt (削除ここまで) : constant-expression
...
virt-specifier:
 override
 final
 (削除) new (削除ここまで)
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 ]

AltStyle によって変換されたページ (->オリジナル) /