This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]