1 泛化仿函数的要求
参数个数应该是任意的,参数的型别也应该是任意的。
// 我们的Functor 应该是这样的,Functor 只是一个 wrapper(外覆类)
template <typename ResultType, typename TList>
class Functor
{
public:
ResultType operator()(); // 转发函数
ResultType operator(Parm1 p1);
ResultType operator(Parm1 p1, Parm2 p2);
.....
};
struct T1
{
double operator()(int, double)
{
// ....
}
};
int foo()
{
//...
}
int main()
{
Functor<double, TYP......
阅读全文