Boost logo

Boost :

From: Noel Yap (Noel.Yap_at_[hidden])
Date: 2003-05-04 11:52:33


Floris van den Berg wrote:
> It can be usefull i guess. If you want to show in your sourcecode that a
> function doesn't care about an initial value in your parameter you'd use
> c_out, otherwise c_in_out. But it's impossible to enforce such a thing (e.g.
> generate a compiler error when the variable IS read), so you would have to
> trust the function implementer that it indeed doesn't care about the initial
> value and so that it doesn't read it.

Right. The only way I can think of to enforce this would be to use
return from the function. For example, rather than:

  void f( out< T > p_ );

use:

  T f();

If, for some reason you T shouldn't be returned directly (eg it's large
or not copyable), either of the following can be used:

  ptr< T > f();
  ref< T > f();

So, why opt for out parameters that aren't really out parameters when a
return value suffices?

Also, wouldn't c_in be more useful than c_out since c_in /can/ be
enforced?

Noel


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