我在 C++ Template: The complete Guide 一书中找到了以下语句:
不允许函数模板的模板模板参数。
但是他跟随一段代码为我编译和运行。
template< typename T, template <typename elem,typename = std::allocator<elem> > class Cont>
void disp(const Cont<T>& t)
{
for(auto it = t.cbegin(); it != t.cend(); ++it)
{
cout<<"Value : "<<*it<<endl;
}
}
int main()
{
int arr[] = {1,2,3,4,5};
std::vector<int> vec(arr, (arr+ sizeof(arr)/sizeof(arr[0])));
disp(vec);
}
这是否意味着新的 C++ 标准支持函数的模板模板参数?以下帖子的答案另有说明: How to get template template argument deduction working with functions?