0

I have the following code which works fine:

template<typename T>
struct Foo
{
    using Bar = int;
};

struct Baz : public Foo<Baz>
{
    Bar bar;
};

Now I want to change Baz to accept a template parameter itself.

template<typename T>
struct Foo
{
    using Bar = int;
};


template<typename T>
struct Baz : public Foo<Baz<T>>
{
    Bar bar;
};

This fails to compile in every compiler with error: unknown type name 'Bar'. In fact, even if I put using Foo<Baz>::Bar; above that line, it still fails. (Yet the using itself compiles file!) Why?

Paul Accisano
  • 1,416
  • 1
  • 14
  • 25

0 Answers0