Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Sepplesfags, help!

Name: Anonymous 2008-12-08 18:34


template <class T>
class A
{
public:
    typedef T Foo;
};

template <class T>
class B
{
    A<T>::Foo foo;
};

int main()
{
    B<int> b;
    return 0;
}



test.cpp:11: error: type ‘A<T>’ is not derived from type ‘B<T>’
test.cpp:11: error: expected ‘;’ before ‘foo’


What the FUCK?

Name: Anonymous 2008-12-09 15:52

Apologies in advance, >>29.

>>27
This error actually caused me a great deal of annoyance. It worked in one compiler, but not another. I switched to:

template<class T>
struct Templategasm {
  struct A { void f() { } };
  struct B : A { void g() { f(); } };
};

int main() {
  Templategasm<int>::B b;
  b.g();
}


rather than explicitly qualifying names everywhere (it's still needed in some places, but it's generally more readable). It works because A becomes a non-dependent base class in Sepplespeak, and is thus checked when looking for non-dependent names. Talk about PIG DISGUSTING.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List