Boost logo

Boost :

From: John Swartzentruber (johnslists_at_[hidden])
Date: 2003-04-24 15:03:46


On Thu, 24 Apr 2003 21:48:02 +0200, Terje Slettebø wrote:

>You must of course do what you think is best in this situation. I just hope
>you got my point that if the calling code uses const, you don't have to look
>at the function signature, to determine what variables may or may not be
>changed by a function.

void func1(Classname& obj)
{
    func2(obj);
    func3(obj);
    func4(obj);
}

You are maintaining someone's code and know that one of these functions
is changing obj. How do you know which? I think I understand your point
about the calling code using const, but in this case, where the object
is non-const within the function because func1() changes the object,
would you call const_cast for the functions that do not change the
object? I think that would clearly document what is going on, but it
seems unlikely that anyone does this when passing non-const references
to functions that take a const references for their parameters. Do you
do this?


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk