-
August 9th, 2009, 06:46 AM
#1
VC2008 refuses to compile the following code, and I can't understand why.
template<typename T> class A {
template<typename U> class B;
template<typename U> class C;
template<typename U> class B {
typedef C<U> D;
D *c;
T u;
};
template<typename U> class C { // It works fine if I change 'C' to 'D' here.
typedef B<U> B;
B *b;
T v; //VC2008 complains about this line, that T is undefined.
};
};
A<int> a;
-
August 9th, 2009, 09:40 AM
#2
Re: VC2008 refuses to compile the following code, and I can't understand why.
Use code tags, so the indentation isn't stripped off.
Code:
template<typename T> class A {
typedef T AT;
template<typename U> class B;
template<typename U> class C;
template<typename U> class B {
typedef C<U> D;
D *c;
typename A::AT u;
};
template<typename U> class C {
typedef B<U> B;
B *b;
typename A::AT v;
};
};
It's a bug. You can explicitly disambiguate things so the compiler doesn't confuse itself.
gg
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|