A
Anthony Heading
Hi all,
I've often found myself wanting to write code like the example here.
Since
both MSVC and gcc both reject it, I suspect it is indeed illegal.
gcc: no type named `Name' in `class Collection<Animal>'
msvc7: error C2039: 'Name' : is not a member of 'Collection<Traits>'
But to me it seems pretty unambiguous, so I can't see why it's wrong.
Could anybody give me a pointer, either to the standard or the basic
rationale why it's an error?
Thanks
Anthony
template <class T>
class Animal
{
typename T::Name name; // This seems to be an ERROR
};
template <
class Collection :
public Traits < Collection<Traits> >
{
public:
typedef char* Name;
};
int main()
{
Collection<Animal> zoo;
return 0;
}
I've often found myself wanting to write code like the example here.
Since
both MSVC and gcc both reject it, I suspect it is indeed illegal.
gcc: no type named `Name' in `class Collection<Animal>'
msvc7: error C2039: 'Name' : is not a member of 'Collection<Traits>'
But to me it seems pretty unambiguous, so I can't see why it's wrong.
Could anybody give me a pointer, either to the standard or the basic
rationale why it's an error?
Thanks
Anthony
template <class T>
class Animal
{
typename T::Name name; // This seems to be an ERROR
};
template <
class Collection :
public Traits < Collection<Traits> >
{
public:
typedef char* Name;
};
int main()
{
Collection<Animal> zoo;
return 0;
}