Trouble with typedefs in Barton-Nackman constructs.
A Gutkin
s9900835@sms.ed.ac.uk
Tue Dec 10 05:22:00 GMT 2002
Hi,
I am having problem with typedefs in a C++ construct known as
Barton-Nackman trick. Trying to compile the following with gcc 3.2.1 (or
any other version up to 2.96):
template <typename T>
struct A {
typedef typename T::element_type element_type;
};
template <typename T>
struct B : public A<B<T> > {
typedef T element_type;
};
int main(void) {
B<float> test;
return 0;
}
gives the following errors:
test.cc: In instantiation of `A<B<float> >':
test.cc:15: instantiated from `B<float>'
test.cc:15: instantiated from here
test.cc:4: no type named `element_type' in `struct B<float>'
I wonder whether this is illegal according to C++ standard, or just a bug
in g++ ?
Any advice would be appreciated,
Alex.
More information about the Gcc
mailing list