Boost logo

Boost :

From: Noel Yap (Noel.Yap_at_[hidden])
Date: 2003-04-24 10:30:29


"Justin M. Lewis" wrote:
> And, it's not either pass in a whole object or pass in a pointer, you're
> forgetting references. This new class takes in a reference, and stores
> that. It doesn't do anything with pointers.

I didn't really forget references. IMHO, references are pointers that
are implicitly dereferenced. At the machine level, they are typically
treated the same (eg address is passed by value).

> And, again, returning an object isn't always desirable, you could be copying
> large objects for no reason. You may not call a copy constructor, but an =
> operator is being used.

My reply to this was to use smart pointers. But as Terje Slettebø
pointed out (but I got distracted by work before sending out my reply),
smart pointers don't resolve the problem that the object may still
change from underneath.

I still think there's no need for the proposed wrapper class since:

  void f( T& value_may_change_, T const& value_may_not_change_ );

is still an acceptible alternative. IOW, if users stick to using T&
only to indicate values that may change, and T const& to indicate values
that may not change, the wrapper class has no added value (forgive the
unintended pun).

Noel

-- 
NOTICE: If received in error, please destroy and notify sender.  Sender
does not waive confidentiality or privilege, and use is prohibited.

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