#ifndef eoFuncPtrStat_h #define eoFuncPtrStat_h #include #include /** Wrapper to turn any stand-alone function and into an eoStat. * * The function should take an eoPop as argument. * * @ingroup Stats */ template class eoFuncPtrStat : public eoStat { public : typedef T (*func_t)(const eoPop&); eoFuncPtrStat(func_t f, std::string _description = "func_ptr") : eoStat(T(), _description), func(f) {} using eoStat::value; void operator()(const eoPop& pop) { value() = func(pop); } private: func_t func; }; /** * @ingroup Stats */ template eoFuncPtrStat& makeFuncPtrStat( T (*func)(const eoPop&), eoFunctorStore& store, std::string description = "func") { return store.storeFunctor( new eoFuncPtrStat( func, description) ); } #endif