Movatterモバイル変換


[0]ホーム

URL:


Issue 1874 - WG21 CWG Issues
Title
Type vs non-type template parameters with class keyword
Status
cd4
Section
13.2 [temp.param]
Submitter
Richard Smith

Created on2014-02-18.00:00:00 last changed109 months ago

Messages

msg5407 (view)
Date: 2014-11-15.00:00:00

[Moved to DR at the November, 2014 meeting.]

msg5143 (view)
Date: 2014-10-15.00:00:00

Proposed resolution (October, 2014):

  1. Change 13.2 [temp.param] paragraph 2 as follows,moving the example from paragraph 3 to paragraph 2:

  2. There is no semantic difference betweenclassandtypename in atemplate-parameter.typename followed by anunqualified-id namesa template type parameter.typename followed byaqualified-id denotes the type in anon-type137parameter-declaration.Atemplate-parameter of the formclassidentifier is atype-parameter.[Example:

      class T { /* ... */ };  int i;  template<class T, T i> void f(T t) {    T t1 = i;      // template-parametersT andi    ::T t2 = ::i;  // global namespace membersT andi  }

    Here, the templatef hasatype-parameter calledT, rather than anunnamed non-typetemplate-parameter of classT. —end example]. A storageclass shall not be specified in atemplate-parameterdeclaration. Types shall not be defined inatemplate-parameter declaration.[Note: Atemplate parameter may be a class template. For example...—end note]

  3. Change 13.2 [temp.param] paragraph 3 as follows,moving the example from paragraph 2 to paragraph 3:

  4. Atype-parameter whose identifier does not followan ellipsis defines itsidentifier to beatypedef-name (if declared withclassortypename) ortemplate-name (if declaredwithtemplate) in the scope of the templatedeclaration.[Note: Because of the name lookuprules, atemplate-parameter that could be interpretedas either a non-typetemplate-parameter oratype-parameter (because its identifier is the nameof an already existing class) is taken asatype-parameter. For example... —endnote][Note: A template parameter maybe a class template. For example,

      template<class T> class myarray { /* ... */ };  template<class K, class V, template<class T> class C = myarray>  class Map {    C<K> key;    C<V> value;  };

    end note]

msg5051 (view)
Date: 2014-02-18.00:00:00

The Standard is not clear enough that a template parameter likeclass T is to be interpreted as a type parameter andnot an ill-formed non-type parameter of class typeT.

History
DateUserActionArgs
2017-02-06 00:00:00adminsetstatus: drwp -> cd4
2015-05-25 00:00:00adminsetstatus: dr -> drwp
2015-04-13 00:00:00adminsetmessages: +msg5407
2014-11-24 00:00:00adminsetstatus: tentatively ready -> dr
2014-10-13 00:00:00adminsetmessages: +msg5143
2014-10-13 00:00:00adminsetstatus: drafting -> tentatively ready
2014-07-07 00:00:00adminsetstatus: open -> drafting
2014-02-18 00:00:00admincreate

[8]ページ先頭

©2009-2026 Movatter.jp