|
Boost : |
From: David Abrahams (dave_at_[hidden])
Date: 2003-11-01 16:17:58
"Fernando Cacciola" <fernando_cacciola_at_[hidden]> writes:
>> struct type
>> {
>> //invariant is x + y = 10
>> int x;
>> int y;
>>
>> void f( int n )
>> {
>> x = n; //* invariant is broken
>> f1(); //* is this allowed?
>> y = 10-n; //* invariant restored
>> }
>>
> The way I see it, if f1() is not public, then the above is most likely OK.
> If is it public, then it is most likely not OK.
Since the class designer has control over the design of f1, whether
it's public or not is not really relevant. Yes, public member
functions tend to require intact invariants, but might not always
require them.
-- Dave Abrahams Boost Consulting www.boost-consulting.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk