
-----Original Message----- From: boost-bounces@lists.boost.org [mailto:boost-bounces@lists.boost.org] On Behalf Of Emil Dotchevski Sent: Thursday, July 27, 2006 2:37 AM To: boost@lists.boost.org 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