* Jean-Louis Leroy:
> Is the following code legal ?
Nope.
> template<typename T>
> struct base
> {
> typedef T type;
> };
>
> template<typename T>
> struct derived : base<T>
> {
> derived(type x);
> };
>
> g++ 3.3.4 and Visual Studio 2005 accept it. OTOH I don't see how they
> recognize "type" as a type name.
Comeau C/C++ 4.3.10.1 (Oct 6 2008 11:28:09) for ONLINE_EVALUATION_BETA2
Copyright 1988-2008 Comeau Computing. All rights reserved.
MODE:strict errors C++ C++0x_extensions
"ComeauTest.c", line 10: error: identifier "type" is undefined
derived(type x);
^
1 error detected in the compilation of "ComeauTest.c".
> I would expect "typename
> base<T>::type" to be required in "derived<T>".
Yep.
Except for one detail in the context of usage as a base class when deriving.
As I recall in that context instead of being required, 'typename' is forbidden.
Cheers & hth.,
- Alf
--
Due to hosting requirements I need visits to [
http://alfps.izfree.com/].
No ads, and there is some C++ stuff!

Just going there is good. Linking
to it is even better! Thanks in advance!