On 29.01.2014 17:12, A wrote:
>
> Is one version preferred over another or faster over another?
I would prefer the one that most closely matches the requirements at
hand and is most clear and simple to understand.
The requirements are however not obvious.
If you need local state then a non-static member function might be it,
but I would prefer a named one rather than operator(), unless this
object has to be passed to other code as a functor.
Otherwise the static member function is good.
You might alternatively consider a named namespace level function placed
in e.g. a `detail` namespace.
Or if this is in a (outer) class, just an ordinary but non-public member
function of that class, instead of doing everything locally, even if in
a sense that is like polluting the class scope with the implementation
details of one of its member functions.
A local lambda would run into the problem of expressing the recursion,
which would necessitate either a local struct or accessing an outside
reference to the lambda (e.g. a `std::function` instance), so that would
just be more complication, not less. I think.
Summing up, one of the four first. ;-)
Cheers & hth.,
- Alf