|
Boost : |
From: Rainer Deyke (root_at_[hidden])
Date: 2002-01-13 10:21:00
----- Original Message -----
From: "Andrei Alexandrescu" <andrewalex_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Sunday, January 13, 2002 3:00 AM
Subject: Re: [boost] Loki SmartPtr questions
> > This would not be a major issue for a rarely used function, but I
have
> > found that I tend to make extensive use of
'boost::shared_ptr::get'.
>
> I'm not trying to make criticisms based on so little information
here, but I
> guess a good design would not need to have access to the underlying
raw
> pointer managed by a smart pointer.
Common situation:
class C;
void foo(C *);
boost::shared_ptr<C> p;
foo(p.get());
I could change 'foo' to accept a 'boost::shared_ptr<C>', but that
would tie 'foo' to a specific smart pointer. I could change 'foo' to
accept a 'C&', but that would make it impossible to pass a null
pointer (there is no null reference). I could turn 'foo' into generic
function, but that causes code bloat and forces me to place the
implementation of 'foo' in a header file. And sometimes 'foo' is from
a third-party library so I can't change it at all, I can only add
another layer above it.
> I guess operator-> should be heavily
> used.
'foo(p.operator->())'? How is that less confusing than
'foo(p.get())'?
-- Rainer Deyke (root_at_[hidden]) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk