Boost logo

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
> > found that I tend to make extensive use of
> 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
> pointer managed by a smart pointer.

Common situation:

  class C;
  void foo(C *);
  boost::shared_ptr<C> p;

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

Rainer Deyke (root_at_[hidden])
Shareware computer games           - 
"In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor

Boost list run by bdawes at, gregod at, cpdaniel at, john at