
Gottlob Frege <gottlobfrege <at> gmail.com> writes: ... I have/had a SBO "DeplorablePimpl" template (see Herb Sutter's http://www.gotw.ca/gotw/028.htm). Basically
class X { DeplorableImpl<42, XImpl> pimpl; };
It takes care of most/all of Sutter's concerns. For example, it checks at compile time (in the cpp file) that sizeof(XImpl) == 42, (or <= 42, depending on policies) and forces correct constructors, etc. It does mean that X needs a constructor and destructor to be defined in the cpp file, not the h file (since the cpp is where XImpl is known, not just declared).
I'm not sure if this could be incorporated as a policy into a general Pimpl, or should be kept somewhat separate. Maybe just same namespace or something.
Oh, yes, I remember this one. :-) I think it might came up during original few-years-old discussion. Back then I remember I was somewhat apprehensive of this design. Now that I am growing old, cuddly and agreeable I do feel that this design has its place... and I dare to say if not prominent then at least an equal place among others. I do not see anything wrong with an optimization if the project specifics warrant/demand that. Say, OTOH for short-lived classes with small XImpl that'd be a *considerable* performance boost. If "my dear" Pimpl survives, I'll be looking into including it as a policy. many thanks, V.