ROOT::Math::WrappedFunction vs ROOT::Math::Functor1D


It seems to me that both classes do the same, i.e. adapt any C++ callable object or free function to ROOT::Math::IBaseFunctionOneDim interface (Functor1D additionally can adapt also a member function). However Functor1D seems to be more indirect - delegates to fImpl instead of delegating directly to adapted object.

Why there are both classes; when should I favour one over the other?


Hi, Antoni.

They are pretty much the same. As you said, Functor1D has one more level of indirection, but WrappedFunction is templated, which may be annoying if you have to type the function type (f.e. when building it on a free function).


Hi Xavi,

Thanks for a reply. However, WrappedFunction has a default template parameter FreeFunctionPtr, so a declaration looks like this:
WrappedFunction<> object(functionName);

Therefore I still don’t see why should I ever use Functor1D…


This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.