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_Inheritance_Arguments_Bind - Fatal编程技术网

C++ 与模板类一起使用的自定义模板参数绑定器

C++ 与模板类一起使用的自定义模板参数绑定器,c++,templates,inheritance,arguments,bind,C++,Templates,Inheritance,Arguments,Bind,我有一个包含3个参数的模板类,我需要在之前绑定其中的2个参数,然后将绑定的版本传递给我继承的“父”template模板类。 (我已经搜索了以前提出的问题,但没有人试图从父项继承。) 我怎样才能让它工作 下面是一个示例代码: template <template<class> class W, class ...D> struct Parent{}; template <class B, class T, class ...D> struct Arg{};

我有一个包含3个参数的模板类,我需要在之前绑定其中的2个参数,然后将绑定的版本传递给我继承的“父”
template模板类。
(我已经搜索了以前提出的问题,但没有人试图从父项继承。)

我怎样才能让它工作

下面是一个示例代码:

template <template<class> class W, class ...D>
struct Parent{};

template <class B, class T, class ...D>
struct Arg{};

template <class B, class ...D>
struct Bind{
    template <class T>
    using arg = Arg<B, T, D...>;
};

template <class B, class ...D>
struct DD : public Parent<Bind<B, D...>::t, D...> //compiler complains*
{ };

 * template argument for template template parameter must be a class template or type alias template.
模板
结构父{};
模板
结构Arg{};
模板
结构绑定{
模板
使用arg=arg;
};
模板
结构DD:公共父级//编译器投诉*
{ };
*模板参数的模板参数必须是类模板或类型别名模板。

我试过使用
typename
关键字;在
Binder
中使用
struct
继承而不是
using指令
,没有任何效果。

首先,您可能指的是
Bind::arg
而不是代码段中的
Bind::t

其次,您需要
template
关键字,因为
Bind
是一个依赖于类型的id表达式。即

模板
结构DD:公共父级
{ };

首先,您可能是指代码段中的
Bind::arg
而不是
Bind::t

其次,您需要
template
关键字,因为
Bind
是一个依赖于类型的id表达式。即

模板
结构DD:公共父级
{ };

欢迎来到StackOverflow!欢迎来到StackOverflow!
template <class B, class ...D>
struct DD : public Parent<Bind<B, D...>::template arg, D...>
{ };