Boost logo

Boost :

Subject: Re: [boost] Pimpl Again?
From: Gavin Lambert (gavinl_at_[hidden])
Date: 2016-05-29 20:08:56

On 28/05/2016 17:41, Vladimir Batov wrote:
> I feel that pimpl and its deployment pattern need to be codified,
> described, "standardized" and in our toolboxes to stop/avoid everyone
> re-inventing the pimpl and making the same mistakes. IMO Boost is best
> positioned for that.
> Do you think we might review what I've got and/or maybe collectively
> come up with something better... It's no MPL or Hana but as
> std::unique_ptr it's one of the first "little things" I personally reach
> out for in my everyday work. IMO having pimpl in Boost would save quite
> a few hours of frustration for many.

I like the idea, certainly. My main concerns about Boost-ification of
this are:

1. The way the docs are structured suggest that the "natural"
implementation is the shared one and the unique implementation is an
extension. Standard C++ language and performance guidelines suggest the
reverse should be preferred (or as Chris suggested, one that avoids heap
allocation entirely). (This is mostly just a doc issue; the actual
implementation seems neutral.)

2. This introduces a symbol (pimpl) into the global namespace, which is
probably against Boost guidelines. But putting it into the boost
namespace doesn't seem like a good solution either as usage requires
explicit template specialisation, which is more clunky if the template
to be specialised is in a different namespace. (Though even being in
the global namespace doesn't avoid this clunkiness, if the user classes
are themselves in a non-global namespace.)

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