On Sunday, March 20, 2016 at 9:07:53 PM UTC-5, Gavin Lambert wrote:
On 21/03/2016 14:20, rstewart wrote:
You state that the function call operator is always declared const. On what basis do you make that claim? It may be a reasonable, even common thing to do, but you should justify your assertion.
On a related note, at least in the codebases I tend to work with, const function objects are the exception rather than the rule.
However, with lambdas it is the opposite. Lambdas default to const and then an explicit mutable keyword is needed for a mutable function object.
While it's likely that some of these could be made const with a little restructuring,
Just like lambdas, mutability is not prohibited in Fit, just explicit.
I think it's still true that mutable functions are useful in more cases -- despite being vulnerable to surprise copies and thread-safety issues.
(Having said that, this may be because boost::bind is used in most cases where const function objects would otherwise be used, so that custom function objects are typically only created where they need to be mutable; the code does not yet make extensive use of lambdas. But I don't think my experience is unique.)
I would like to note, that the const requirement only applies to function objects. You can pass member function pointers to member functions that are mutable.
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost