
Hi All
I've been experimenting with pimpl recently. What I've seen written about
the pimpl idiom is that you have an interface class and an implementation
class, and in the interface class you put some kind of pointer to the
implementation.
However, I thought, sometimes you might want that to be a shared pointer. Or
an intrusive pointer. Or unique pointer. Or maybe sometimes you might decide
not to use pimpl at all.
I thought it was a bit silly that you had to make these decisions at the
time you create the interface class. I thought it would be nice if you could
write the interface independent of how it was going to be connected to the
implementation, and then hook them together however you like.
So this is what I've done. Basically I've broke things up into three
separate parts:
(1) Interface
(2) Implementation
(3) What joins them together (i've created unique_pimpl and shared_pimpl as
examples)
I've implemented a unique_ptr and shared_ptr pimpl implementations as
examples. The idea is that you can basically do this:
unique_pimpl