【发布时间】:2016-11-03 23:54:42
【问题描述】:
我有以下结构和功能
template <class T> struct C {};
template <template <class S> class T, class U> void f() { T<U> tu; }
当用C 模板化f() 时,我没有收到错误,当用std::vector 模板化它时我会。
int main() {
f<C, int>();
}
没有错误
int main() {
f<std::vector, int>();
}
产量
error: no matching function for call to 'f'
f<std::vector, int>();
^~~~~~~~~~~~~~~~~~~~~~~~
note: candidate template ignored: invalid explicitly-specified argument for template parameter 'T'
template <template <class S> class T, class U> void f() { T<U> tu; }
这里C和std::vector有什么区别?
【问题讨论】:
标签: c++ templates stl template-templates