Movatterモバイル変換


[0]ホーム

URL:


Issue 108 - WG21 CWG Issues
Title
Are classes nested in templates dependent?
Status
tc1
Section
13.8.3.2 [temp.dep.type]
Submitter
Mark Mitchell

Created on1999-04-14.00:00:00 last changed48 months ago

Messages

msg6641 (view)
Date: 2000-10-15.00:00:00

Proposed resolution (10/00):

Add after 13.8.2 [temp.local] paragraph 2:

Within the scope of a class template, when the unqualified name of anested class of the class template is referred to, it is equivalent tothe name of the nested class qualified by the name of the enclosingclass template. [Example:
    template <class T> struct A {class B {};// B is equivalent to A::B, which is equivalent to A<T>::B,// which is dependent.class C : B { };    };
end example]
msg328 (view)
Date: 2000-10-15.00:00:00

Proposed resolution (10/00):

Add after 13.8.2 [temp.local] paragraph 2:

Within the scope of a class template, when the unqualified name of anested class of the class template is referred to, it is equivalent tothe name of the nested class qualified by the name of the enclosingclass template. [Example:
    template <class T> struct A {class B {};// B is equivalent to A::B, which is equivalent to A<T>::B,// which is dependent.class C : B { };    };
end example]
msg166 (view)
Date: 2022-11-20.07:54:16

Mark Mitchell (via John Spicer): Given:

  template <class T> struct S {     struct I1 {       typedef int X;     };     struct I2 : public I1 {        X x;     };  };

Is this legal? The question really boils down to asking whether ornotI1 is a dependent type. On the one hand, it doesn't seem to fitany of the qualifications in 13.8.3.2 [temp.dep.type].On the other, 13.9.4 [temp.expl.spec] allowsexplicit specialization of a member class of a class template, so somethinglike:

  template <>  struct S<double>::I1 {     int X;  };

is apparently legal. But, then, `X' no longer refers to a type name.So, it seems like `I1' should be classified as dependent. What am Imissing?

Erwin Unruh: I wrote that particular piece of text and I justmissed the problem above. It is intended to be a dependent type. Thereasoning is thatI1 is just a shorthand forS<T>::I1 which clearly isdependent.

Suggested Resolution: (Erwin Unruh)

I think the list of what is a dependent type should be extended to cover"a type declared and used within the same template" modulo ofphrasing.

(See also paper J16/00-0009 = WG21 N1231. This issue is alsosomewhat related toissue 205: classesnested inside template classes are, in some sense, "templates," justas non-template member functions of class templates and static datamembers of class templates are "templates.")

History
DateUserActionArgs
2022-02-18 07:47:23adminsetmessages: +msg6641
2003-04-25 00:00:00adminsetstatus: dr -> tc1
2000-11-18 00:00:00adminsetstatus: ready -> dr
2000-05-21 00:00:00adminsetmessages: +msg328
2000-05-21 00:00:00adminsetstatus: drafting -> ready
2000-02-23 00:00:00adminsetstatus: open -> drafting
1999-04-14 00:00:00admincreate

[8]ページ先頭

©2009-2026 Movatter.jp