1.如标题所说,也就是在模板中嵌入另一个模板举个例子:
template<typename T,
template <typename T>
class Container
>
class XCls
{
private:
Container<T> c;
public:
....
};
那么怎么取使用呢?
template<typename T>
using Lst = list<T,allocator<T>>;
XCls<string,list> mylst1; X
XCls<string,Lst> mylst2;
这里得第二段第一行,mylst1得意思就是,传进去得参数是个list模板,但是这一句是错误得,
因为在真正用得时候,这个list也就是Container要拿去list<string> c;这样看是可以得,但是容器有第二模板参数。
在语法上面是过不去得。
要解决这种问题得话,就使用:
template<typename T>
using Lst = list<T,allocator<T>>;
2.如上所说,因为容器可能会有第二第三模板参数,那么假如我们传入得是一个智能指针?