From: Rob Stewart (stewart_at_[hidden])
Date: 2005-10-04 11:32:13
From: Caleb Epstein <caleb.epstein_at_[hidden]>
> On 10/4/05, Rob Stewart <stewart_at_[hidden]> wrote:
> > For pimpl to work, the implementation class must be complete when
> > you try to use it. No library can eliminate that.
> Or the Interface class provides methods that forward to the Implementation
Those Interface class member functions *use* the implementation
class. The implementation class must be complete for those
member functions, which is what I wrote.
The usual structure is forward declaration in the header and then
definition and use in the implementation file.
> I guess my problem is one of terminology. In my mind, a Pimpl class holds
> the pointer to the Implementation as well as providing the methods that
> forward to the Implementation. This implementation only holds the pointer
> and manages the memory, which makes me think it should be called a
> PimplHolder, and not a Pimpl.
There's your problem. A "pimpl" is a pointer to an
implementation class instance. "pimpl" can be thought of as a
contraction of "pointer to implementation," if you like. It
actually arose because many like to name such pointer data
members "pImpl" or "pimpl" (often with additional adornments),
but then those names came from contracting "pointer to...."
Anyway, the class that *has* a pimpl can actually have many, but
usually has only one. That class simply uses the pimpl as a
means to hide implementation details, often to improve
compilation times or to decouple code.
-- Rob Stewart stewart_at_[hidden] Software Engineer http://www.sig.com Susquehanna International Group, LLP using std::disclaimer;
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk