Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/125.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

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

C++ 混乱的模板代码

C++ 混乱的模板代码,c++,templates,C++,Templates,下面这句话是什么意思 template < template < template < class > class, class > class Param > templateclass参数> 我从未使用过模板这种语法 从另一个人那里弄来的 templateclass参数> 结构伪造{ int foo(){ printf(“ok\n”);; } }; 请欣赏任何关于这个语法的说明。多谢各位 更新:看起来已经有了一些解释,请参考下面Jerry的解决方案,

下面这句话是什么意思

template < template < template < class > class, class > class Param >
templateclass,class>class参数>
我从未使用过
模板
这种语法

从另一个人那里弄来的

templateclass,class>class参数>
结构伪造{
int foo(){
printf(“ok\n”);;
}
};
请欣赏任何关于这个语法的说明。多谢各位


更新:看起来已经有了一些解释,请参考下面Jerry的解决方案,它被称为模板参数。之前已经讨论过多次:




等等。

在C++中有三个本体层:值、类型和模板

模板实例化是一种类型。对象是特定类型的,并且具有值

所有三种类型的实体都可以显示为模板参数:

template <int N, typename T, template <typename> C>
{
  C<T> array[N];
};

模板的新C++11语法。请参阅下面的链接。@AJG85:新的C++11语法?真的吗?哦,只是在谷歌上搜索了一下。对我来说,新的东西。C++中的很多东西,我不断学习,更多的东西不断出现:D希望有一本圣经。谢谢你,杰瑞
template <int N, typename T, template <typename> C>
{
  C<T> array[N];
};
template <typename T, template <typename...> Container>
void print(const Container<T> & c)
{ /* ... */ }
template <typename T> struct Foo
{
  T value;
  typedef T * pointer;
  template <typename S> struct Nested;
};

// now refer to them as:
Foo<T>::value;
typename Foo<T>::pointer;
template<typename S> Foo<T>::template Nested<S>;