模板类的第三个参数也是个模板类,但是为什么是
template<class>
而不是
template<class T>
template<class>
而不是
template<class T>
解决方案
10
原因是其它地方没有用到那个参数,不需要写名字,就跟h函数声明中的参数可以不写名字一样。
10
可写可不写。
10
模板的模板参数(template template parameter)
这名字挺绕的,而且用之前要三思这东西能否真的能达到预期的效果,二十年前标准库差点要使用这东西,后来发现它的功能不能完全满足需求
这名字挺绕的,而且用之前要三思这东西能否真的能达到预期的效果,二十年前标准库差点要使用这东西,后来发现它的功能不能完全满足需求
10
模板模板参数
LimitFunc 是 有一个模板参数的模板
MSDN 例子
LimitFunc 是 有一个模板参数的模板
MSDN 例子
// template_specifications3.cpp
#include <stdio.h>
template <class T> struct str1
{
T t;
};
template <template<class A> class T> struct str2
{
T<int> t;
};
int main()
{
str2<str1> mystr2;
mystr2.t.t = 5;
printf_s("%d\n", mystr2.t.t);
}