Boost logo

Boost :

From: Richard Hadsell (hadsell_at_[hidden])
Date: 2003-09-11 09:05:37


Daniel Frey wrote:

> ...
> if (ptr.get()) ...
> if (ptr) ... // Less efficient.
> ...
> As I think that efficiency is more important than a nice error
> message, I'd like to propose changing shared_ptr's code appropriately
> to avoid the overhead imposed by the current safe-bool-idiom. Comments?

I was interested in this thread, because I use scoped_ptr and
scoped_array extensively, and performance is important for my
application. I was glad to see the bool operator added to those
classes, and I laboriously changed all my 'if (ptr.get())'s to 'if
(ptr)', not realizing the compiler might not generate code as efficient.

Is it true that the discussion applies to the scoped_ classes as well as
shared_ptr? And is someone willing to fix them, too?

I would like to avoid changing back to the 'if (ptr.get())' form, if
there might be a fix in the near future.

-- 
Dick Hadsell			914-259-6320  Fax: 914-259-6499
Reply-to:			hadsell_at_[hidden]
Blue Sky Studios                http://www.blueskystudios.com
44 South Broadway, White Plains, NY 10601

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