假设我们有一个类
template <int(*F)(int, int)>
class A {
// ...
};
它接受一个函数作为模板参数。
现在我想做一个可变模板,它以函数作为模板参数。
template <int(*F...)(int, int)> // this won't compile
template <int(*F)(int, int)...> // this won't compile either
如何正确地做到这一点?
发布于 2014-10-09 16:33:33
template <int(*...F)(int, int)>
class A {
// ...
};
发布于 2014-10-10 02:11:27
函数指针类型语法很烦人。因此,围绕它编写代码:
template<class T> using type=T;
template< type<int(int,int)>* ... Fs >
class A {
};
https://stackoverflow.com/questions/26273765
复制相似问题