Date: 1999-12-29 14:08:17
I am completely convinced by your example. There are no good alternatives
that I can think of.
However, I would like to change it to return a constant object. This would
prevent code such as:
// x is an auto object
// k is a public integer data member on the function object
x.action().k = 13;
which may lead the user to believe that he has changed the value of x's
function object, when in fact that line of code does nothing. Returning a
constant object will not allow this code to compile.
Are there any drawbacks to returning a const object instead of an object?
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk