Boost logo

Boost :

From: Justin M. Lewis (boost_at_[hidden])
Date: 2003-05-03 18:13:12


----- Original Message -----
From: "Noel Yap" <Noel.Yap_at_[hidden]>
To: "Boost mailing list" <boost_at_[hidden]>
Sent: Saturday, May 03, 2003 4:13 PM
Subject: Re: [boost] Re: in/out parameters, codingstylesandmaintenance

> Noel Yap wrote:
> > std::auto_ptr< T > t( new T() );
> > f( boost::dumb_ptr< T >( t.get() ); // clearly an in/out parameter
>
> Or if you don't want to dynamically allocate t:
>
> T t;
> f( boost::dumb_ptr< T >( &t ) ); // clearly an in/out parameter
>
> static T t;
> f( boost::dumb_ptr< T >( &t ) ); // clearly an in/out parameter
>
> boost::dumb_ptr< T > t = f(); // must be an out parameter whose memory
> is managed by f()
>
> T t = *f().get(); // must be an out parameter whose memory is managed
> by f()
>
> T &t = *f(); // must be an out parameter whose memory is managed by
> f()
>

I'm going to have to disagree with those being clearly in_out params. What
if the function just takes a pointer? While we do tend to avoid using
pointers these days, it's not possible to avoid them entirely, and there is
a lot of code where pointers are being passed around. So, how do you
differentiate the case where it's just a pointer being passed, and it's an
in_out param? And, there's still the issue of, we LIKE to avoid using
pointers whenever possible, which you're not doing, you're requiring the use
of pointers in a case where they're easily avoidable.

> Noel
> _______________________________________________
> Unsubscribe & other changes:
http://lists.boost.org/mailman/listinfo.cgi/boost
>


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