Boost logo

Boost :

From: Persson Jonas (jonas.persson_at_[hidden])
Date: 2003-04-24 16:25:51


> So then what's wrong with:
>
> void f( T const& obj_ ); // f will not change obj_
> void f( T& obj_ ); // f may change obj_

They look identical at the caller's site, making the life harder for the
maintanance programmers.
 
> Can you explain the difference between:
>
> f( const_cast< T const& >( _obj ) );
>
> and
>
> f( in_out( _obj ) );

The first is a user of f() writing a comment in a complicated way.
The second is the author of f() enforcing self documenting code.

> And what would happen if someone doesn't use this nifty new class?
It would fail to compile.

> In fact, it sounds like you don't even need a class:
>
> #define in_out( obj ) obj

No, this is not enforced by the compiler. It is no better than a comment.

As I understand it, the whole point of this this proposal is to have a tool
for making the compiler enforce self documenting code.


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