Re: typedef for template
Am 25.07.2011 23:57, schrieb Venkat S:
Hi,
I've searched and not found any reference for this, so I thought
it's ok to post.
template<typename T> class Foo { ... };
template<typename X> class Bar {
typedef Foo<X> Foo; // is this a legal c++ construct?
Foo fooObj;
};
Thanks
Venkat
PS: Had gone through s14 (Working Draft, 2011-02-28 N3242==11-0012),
but couldn't locate any formal description.
It seems to me that this example should be covered by 3.3.7
[basic.scope.class] p1 and should be ill-formed because the name 'Foo'
does not refer to exactly the same declaration. The most specific
standardeze seems to be that of bullet (2):
"A name N used in a class S shall refer to the same declaration in its
context and when re-evaluated in the completed scope of S. No diagnostic
is required for a violation of this rule."
One comparable example is this one:
typedef int I;
class D {
typedef I I; // error, even though no reordering involved
};
HTH & Greetings from Bremen,
Daniel Kr?gler
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]