Boost logo

Boost :

From: Aljaz Noe (aljaz.noe_at_[hidden])
Date: 2006-07-27 18:03:17


> -----Original Message-----
> From: boost-bounces_at_[hidden]
> [mailto:boost-bounces_at_[hidden]] On Behalf Of Emil Dotchevski
> Sent: Thursday, July 27, 2006 2:37 AM
> To: boost_at_[hidden]
> Subject: Re: [boost] pimpl pointer revisited
>
> For pimpl, I personally use boost::shared_ptr. Sure it has
> the "overhead" of the control block, but since how you
> implement pimpl is (duh!) an implementation detail,
> shared_ptr is perfect for a default implementation.
> So if I need to, I can simply convert it to a raw pointer
> later. But consider that the object the shared_ptr points to
> is usually rather complex, and therefore the additional space
> requirements to store the shared_ptr control block are
> unlikely to cause problems.

True. But there are also small implementation details that may be beneficial
to hide.

A typical example that I have come across most often, is a handle to some
system resource to which the class is a wrapper. Since a system handle is a
small object, allocating it on the heap may not be the most efficient way of
doing things. Consequently, many developers abandon the PIMPL idiom
altogether and place the handle object in class as a member. This results in
a dependency on otherwise unnecessary system includes for all users of the
class.

Aljaz


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