Lars Gullik Bjønnes wrote: > Also the reason why I did all this was a direct result of reading > "Effective STL" by Scott Meyers. > > Main recommandations about functors: > > - operator() should always be const > (functors might be copied around by standard > algorightms so depending on local varibles in the > functor is _very_ bad, avoid it with const.) > - functors should be adaptable (ie. be made to work with > standard > function adaptors), this is most easily done with > deriving functors from std::unary_function of > std::binary_function. > > ...also I have read a bit further now :-) and am not sure I agree > with my patch anymore. I think especially maintaince has got harder > with my patch, so I need to modify a bit...
Yes, it's a good book. I note a couple of functors in your patch where the operator() is const but the variables have become mutable. That seems to me to be a total cheat ;-) -- Angus