This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Trouble with typedefs in Barton-Nackman constructs.
- From: A Gutkin <s9900835 at sms dot ed dot ac dot uk>
- To: gcc at gcc dot gnu dot org
- Date: Tue, 10 Dec 2002 11:51:28 +0000 (GMT)
- Subject: Trouble with typedefs in Barton-Nackman constructs.
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.