From: Jesse Perla on
I have some functors that have more data that I might wish and
algorithms that execute them (e.g. some weird multidimensional
interpolators, etc.). I wrote some algorithms that accept these by
constant reference, with the assumption that the function supplies a
const operator(). i.e. stuff like:
template<typename F> double f(const F& f)
return f(.1);

I realize that the std algorithms always pass functors by value. What
is the reasoning for this with stateless algorithms like find
predicates, transform, etc. (I can see why std::generate might want a
copy by value)? Is it just to allow the functors to have a non-const
operator()? Are there any other reasons, such as lack of inlining
with modern compilers, that I can't pass const&?


[ See for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]