|
Boost : |
From: Jurko (Jurko_at_[hidden])
Date: 2002-08-01 11:03:54
How about this example:
// Some kind of a container class. Has a non const
// member function void add( const Value& ) which adds
// another value to the the container.
class A;
// A useful utility function.
void foo( const A& );
// A function that returns an object of class A by value.
const A bar( void );
Now we couldn't do this:
foo( bar().add( someMissingValue ) );
And in order to achieve the same effect we would have to
eather copy the object returned by bar (potentially very
expensive!) or give up using the useful foo function in this
case (assuming we can't or don't want to change how foo()
or bar() work).
But then again I'm using the const value return rule and never
came up against a real-world case where it presented even a
slight problem.
Jurko
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk