www.digitalmars.com         C & C++   DMDScript  

c++.beta - referencing nested templates

reply Richard Grant <fractal clark.net> writes:
We talked about his one before. This fails due to the "typename A<T>::template",
and works with "typename A<T>::" syntax.

template<class T> struct A {
template<class U> struct B {
typedef int type;
};
};

template<class T> struct C {
typedef typename A<T>::template B<int>::type type;
// Error: identifier expected
};

void main() {
C<int> c;
}

The iterator adaptor lib and lower level libs that it depends on favor nested
template references. There is a directive that attempts to work around this
problem, but it is *not* implemented in this lib hierarchy. Fixing this would
allow unpatched compilation of iterator adaptor lib.

Richard
Jan 24 2003
parent reply "Walter" <walter digitalmars.com> writes:
You can work around it for now by simply replacing ::template with ::.

"Richard Grant" <fractal clark.net> wrote in message
news:b0r6mi$tj0$1 digitaldaemon.com...
 We talked about his one before. This fails due to the "typename
A<T>::template",
 and works with "typename A<T>::" syntax.

 template<class T> struct A {
 template<class U> struct B {
 typedef int type;
 };
 };

 template<class T> struct C {
 typedef typename A<T>::template B<int>::type type;
 // Error: identifier expected
 };

 void main() {
 C<int> c;
 }

 The iterator adaptor lib and lower level libs that it depends on favor
nested
 template references. There is a directive that attempts to work around
this
 problem, but it is *not* implemented in this lib hierarchy. Fixing this
would
 allow unpatched compilation of iterator adaptor lib.

 Richard
Jan 24 2003
parent Richard Grant <fractal clark.net> writes:
In article <b0s89v$1elh$1 digitaldaemon.com>, Walter says...
You can work around it for now by simply replacing ::template with ::.

"Richard Grant" <fractal clark.net> wrote in message
news:b0r6mi$tj0$1 digitaldaemon.com...
 We talked about his one before. This fails due to the "typename
A<T>::template",
 and works with "typename A<T>::" syntax.
Ok, member template keyword ala A::template B<> works in fine. But inheritance using this sytax fails to compile: struct B { template <class T> struct C { }; }; template <class T> struct A : B::template C<T> { }; //Error: identifier or '( declarator )' expected int main() { A<int> a; } Richard
Mar 16 2003