仿函数示例
template<typename ReturnType, typename OutterType, typename ArgType>
struct UnaryOperator
{
private:
OutterType& outter;
ReturnType(OutterType* method)(ArgType);
public:
UnaryOperator(OutterType &outter, ReturnType(OutterType::* method)(ArgType)) : outter(outter), method(method)
{
}
ReturnType operator()(ArgType arg)
{
return (outter.*method)( arg );
}
}
//用法:
MyClass myClass;
GetFiles(TEXT("C:\\"), UnaryOperator<BOOL, MyClass, const String&>(myClass, &(MyClass::addFilePath2Arr)));