On 05/30/2016 10:08 AM, Gavin Lambert wrote:
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.)
As you point out the described is "just a doc issue". In that light I do not quite understand how it can be a "main concern". I'll certainly be re-working docs when/if the time comes. At this point IMO we should decide if we want pimpl in Boost and if the suggested design could be used as the starting point.
2. This introduces a symbol (pimpl) into the global namespace, which is probably against Boost guidelines.
Again, I feel you are rushing things. Adapting doccs and putting it into Boost namespace are minor issues to be addressed in due course.
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.
Indeed. Visual Studio did not have that problem for quite some time. GCC had that "clunkiness" a few years ago. Now I try with gcc-4.8: namespace boost { template<class user_type> struct pimpl {...}; } struct Shared : public boost::pimpl<Shared>::shared { ... }; Works fine.
(Though even being in the global namespace doesn't avoid this clunkiness, if the user classes are themselves in a non-global namespace.)
That's something I do not understand. I have plenty of classes like: template<> struct pimplchart::panel::leg::implementation.