Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 从嵌套在类模板中的类模板派生,所有这些都使用类模板_C++_Templates_Template Meta Programming_Crtp - Fatal编程技术网

C++ 从嵌套在类模板中的类模板派生,所有这些都使用类模板

C++ 从嵌套在类模板中的类模板派生,所有这些都使用类模板,c++,templates,template-meta-programming,crtp,C++,Templates,Template Meta Programming,Crtp,我正在努力让这一切顺利进行: template<template<typename> class... Attributes> struct Skills { template<class DERIVED> struct Create : public Attributes<DERIVED>... {}; }; template <class T, class SKILLS> class Tester : pu

我正在努力让这一切顺利进行:

template<template<typename> class... Attributes>
struct Skills
{
    template<class DERIVED>
    struct Create : public Attributes<DERIVED>...
    {};
};

template <class T, class SKILLS>
class Tester : public typename SKILLS::Create<Tester<T,SKILLS>>
{}
模板
结构技能
{
模板
结构创建:公共属性。。。
{};
};
模板
类测试员:公共类型名技能::创建
{}
但编译器抱怨:

错误C2518:基类列表中的关键字“typename”非法;忽略

但是,如果我不在类模板中进行派生,那么这种方法可以很好地工作

是否有机会从嵌套模板类派生?

为什么我需要这个?我正在尝试为CRTP类模板实现一个更好的接口,它允许执行以下操作:

using MyClass = ClassWithAttributes<Skills<Plus,Minus,Equal,Clear,Size>>
使用MyClass=ClassWithAttributes
你必须写

template <class T, class SKILLS>
class Tester : public SKILLS::template Create<Tester<T,SKILLS>>
{ };
模板
类测试员:公共技能::模板创建
{ };
我是说

(1) no
typename
:在基类列表中,隐含参数是类型

(2) 在创建
之前,您需要
模板

(3) 使用
SKILLS
作为
Tester
的参数,而不是
SKILLS
,因为您已经声明了模板参数
SKILLS

(4) 记住类定义末尾的分号

谢谢,就这样。这(3)只是一个打字错误,我编辑了这个。