有没有做到以下几点直接的方式:C++“延迟”模板参数
template <class>
struct f {};
template < class F >
void function() {
F<int>(); //for example
// ? F template <int>();
}
function <f>();
我以围绕模板结构额外的类解决办法。 我想知道是否可以直接这样做。
感谢
有没有做到以下几点直接的方式:C++“延迟”模板参数
template <class>
struct f {};
template < class F >
void function() {
F<int>(); //for example
// ? F template <int>();
}
function <f>();
我以围绕模板结构额外的类解决办法。 我想知道是否可以直接这样做。
感谢
模板模板参数的正确语法如下
template <class> struct f {};
template < template <class> class F >
void function() {
F<int>(); //for example
}
...
function <f>()
我知道我以前看过这个语法。现在我真的知道如何使用它。 spasibo – Anycorn 2010-04-28 05:15:22
哇!没有看到模板
@sharptooth:这里没多少东西要读。就像使用普通的函数参数一样,如果你不使用模板参数,你不必命名它。 – AnT 2010-04-28 05:33:34
我不明白背后的意图。你想达到什么目的? – sharptooth 2010-04-28 05:10:37
@sharp实例化模板里面的函数(上面只是例子) – Anycorn 2010-04-28 05:16:21