当派生类型本身是模板时,CRTP无法继承嵌套类型和使用方法吗?

问题描述

我有下面的代码可以正常工作:

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

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

现在,我想更改Baz以接受模板参数本身。

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


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

这无法在每个使用error: unkNown type name 'Bar'的编译器中进行编译。实际上,即使我将using Foo<Baz>::Bar;放在该行的上方,它仍然会失败。 (但是使用本身会编译文件!)为什么?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)