Movatterモバイル変換


[0]ホーム

URL:


Issue 1435 - WG21 CWG Issues
Title
template-id as the declarator for a class template constructor
Status
cd3
Section
9.3.4 [dcl.meaning]
Submitter
Johannes Schaub

Created on2011-12-24.00:00:00 last changed145 months ago

Messages

msg3888 (view)
Date: 2013-04-15.00:00:00

[Moved to DR at the April, 2013 meeting.]

msg3756 (view)
Date: 2012-10-15.00:00:00

Proposed resolution (October, 2012):

  1. Change 9.3.4 [dcl.meaning] paragraph 1 as follows:

  2. A list of declarators appears after an optional (9.1 [dcl.pre])decl-specifier-seq (9.2 [dcl.spec]). Each declaratorcontains exactly onedeclarator-id; it names the identifierthat is declared. Anunqualified-id occurring in adeclarator-id shall be a simpleidentifier except forthe declaration of some special functions (11.4.5 [class.ctor], 11.4.8 [class.conv], 11.4.7 [class.dtor], 12.4 [over.oper]) and for the declaration oftemplate specializations or partial specializations (13.9 [temp.spec]). Adeclarator-id shall not...
  3. Change 11.4.5 [class.ctor] paragraph 1 as follows:

  4. Constructors do not have names.A special declarator syntax isused to declare or define the constructor. The syntax uses:

    • an optionaldecl-specifier-seq in which eachdecl-specifier is either afunction-specifier orconstexpr,

    • the constructor's class name, and

    • a parameter list

    in that order. In such a declaration, optional parenthesesaround the constructor class name are ignored.Adeclaration of a constructor uses a function declarator (9.3.4.6 [dcl.fct]) of the form

      ptr-declarator(parameter-declaration-clause)exception-specificationopt attribute-specifier-seqopt

    where theptr-declarator consists solely of anid-expression, an optionalattribute-specifier-seq, andoptional surrounding parentheses, and theid-expression hasone of the following forms:

    • in amember-declaration that belongs to themember-specification of a class but is not a friend declaration(11.8.4 [class.friend]), theid-expression is theinjected-class-name (Clause 11 [class]) of theimmediately-enclosing class;

    • in amember-declaration that belongs to themember-specification of a class template but is not a frienddeclaration, theid-expression is aclass-name thatnames the current instantiation (13.8.3.2 [temp.dep.type]) of theimmediately-enclosing class template; or

    • in a declaration at namespace scope or in a friend declaration, theid-expression is aqualified-id that names a constructor(6.5.5.2 [class.qual]).

    Theclass-name shall not be atypedef-name. In a constructor declaration, eachdecl-specifier in the optionaldecl-specifier-seq shallbefriend,inline,explicit, orconstexpr. [Example:...

  5. Delete 11.4.5 [class.ctor] paragraph 3:

  6. Atypedef-name shall not be used as theclass-name inthedeclarator-id for a constructor declaration.
  7. Change 11.4.5 [class.ctor] paragraph 4 as follows:

  8. A constructor shall not bevirtual (11.7.3 [class.virtual]) orstatic (11.4.9 [class.static]). Aconstructor can be invoked for aconst,volatile orconst volatile object.A constructor shall not bedeclaredconst,volatile, orconst volatile(_N4868_.11.4.3.2 [class.this]).const andvolatile semantics (9.2.9.2 [dcl.type.cv]) are notapplied on an object under construction. They come into effect whenthe constructor for the most derived object (6.8.2 [intro.object])ends.A constructor shall not be declared with aref-qualifier.
  9. Change 11.4.5 [class.ctor] paragraph 9 as follows:

  10. No return type (not evenvoid) shall be specified for aconstructor. Areturn statement in the body of aconstructor shall not specify a return value. The address of aconstructor shall not be taken.
  11. Change 11.4.7 [class.dtor] paragraphs 1-2 as follows:

  12. A special declarator syntax using an optionalfunction-specifier (9.2.3 [dcl.fct.spec]) followed by~ followed by the destructor's class name followed by anempty parameter list is used to declare the destructor in a classdefinition. In such a declaration, the~ followed by thedestructor's class name can be enclosed in optional parentheses; suchparentheses are ignored. Atypedef-name shall not be used asthe class-name following the~ in the declarator for adestructor declaration.A declaration of a destructor uses afunction declarator (9.3.4.6 [dcl.fct]) of the form

      ptr-declarator(parameter-declaration-clause)exception-specificationopt attribute-specifier-seqopt

    where theptr-declarator consists solely of anid-expression, an optionalattribute-specifier-seq,and optional surrounding parentheses, and theid-expression hasone of the following forms:

    • in amember-declaration that belongs to themember-specification of a class but is not a friend declaration(11.8.4 [class.friend]), theid-expression is~class-name and theclass-name is theinjected-class-name (Clause 11 [class]) of theimmediately-enclosing class;

    • in amember-declaration that belongs to themember-specification of a class template but is not a frienddeclaration, theid-expression is~class-name and theclass-name names the current instantiation (13.8.3.2 [temp.dep.type]) of the immediately-enclosing class template;or

    • in a declaration at namespace scope or in a friend declaration, theid-expression isnested-name-specifier~class-name and theclass-name names the sameclass as thenested-name-specifier.

    Theclass-name shall not be atypedef-name. Adestructor shall take no arguments (9.3.4.6 [dcl.fct]). In adestructor declaration, eachdecl-specifier of the optionaldecl-specifier-seq shall befriend,inline,orvirtual.

    A destructor is used to destroy objects of its class type.Adestructor takes no parameters, and no return type can be specifiedfor it (not evenvoid). The address of a destructorshall not be taken.A destructor shall not bestatic. A destructor can be invoked for aconst,volatile orconst volatileobject.A destructor shall not be declaredconst,volatile orconst volatile (_N4868_.11.4.3.2 [class.this]).const andvolatile semantics(9.2.9.2 [dcl.type.cv]) are not applied on an object underdestruction. They stop being in effect when the destructor for themost derived object (6.8.2 [intro.object]) starts.Adestructor shall not be declared with aref-qualifier.

    This resolution also resolvesissue 344.

msg3630 (view)
Date: 2011-12-24.00:00:00

The status of a declaration like the following is unclear:

  template<typename T> struct A {    A<T>();  };

9.3.4 [dcl.meaning] paragraph 1 appears to say that it isnot allowed, but it is not clear.

History
DateUserActionArgs
2014-03-03 00:00:00adminsetstatus: drwp -> cd3
2013-10-14 00:00:00adminsetstatus: dr -> drwp
2013-05-03 00:00:00adminsetstatus: ready -> dr
2012-11-03 00:00:00adminsetstatus: review -> ready
2012-09-24 00:00:00adminsetmessages: +msg3888
2012-02-27 00:00:00adminsetmessages: +msg3756
2012-02-27 00:00:00adminsetstatus: open -> review
2011-12-24 00:00:00admincreate

[8]ページ先頭

©2009-2026 Movatter.jp