On const and the lack thereof

J

James Kanze

On 6 Jul. Daniel wrote:

[...]
So the interface says that your Cost Functor should stay constant when
being used, IOW using it should no change its internal state. I can't
imagine what the rationale behind this decision should be, but maybe
there _is_ a quite good reason.

This looks very much like a callback, to be passed by reference
to some other function. One possible reason why the function is
const is that the author of the other function wanted to support
using a temporary object as an argument (and it didn't occur to
him that someone might need a mutable functional object).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,142
Latest member
DewittMill
Top