Rob Stewart wrote:
On March 4, 2016 3:27:08 PM EST, Paul Fultz II
wrote: The library could switch to using `Callable`, if everyone feels that is better. However, I honestly prefer to make mutable explicit. I would like to hear feedback from other reviewers as well.
I do not object to your requiring ConstCallable. I made boost/std::bind const-neutral because this felt the right thing to do - it's not bind's job to tell you what your function object ought to do, it just reflects whatever it does. At the same time, stateful function objects do have limited applicability outside of for_each which specifically guarantees order and returns the function object. You could pass bind( ++_1, 0 ) to generate_n and that's pretty much it. So I do not see the requirement as a defect warranting rejection. If users demand Callable support, you'll add it. If not, not.
If your library only requires Callable, then users can supply a Callable or a ConstCallable. When you require a ConstCallable, they cannot supply a Callable. There may be valid reasons for that restriction in certain cases, but they should be documented rather than just imposed as a convention.
That's true in principle. In practice though function objects that are not ConstCallable are in 90% of the cases the result of a forgotten 'const' on operator() and not a deliberate decision. So requiring ConstCallable catches errors.