Comment by dvratil

4 days ago

It's often used in libraries where you need to guarantee ABI compatibility. Fixing a bug or implementing a feature may require adding a new member into the class, which would change its size (thus break ABI compatibility). PIMPL is the typical solution here, since the inner/impl class is not part of the public ABI.

I also like to use it sometimes to "hide" private methods and their documentation into PIMPL, so the public header is kept clean.

> PIMPL is the typical solution here, since the inner/impl class is not part of the public ABI.

Yep, that's what I've used it for. Didn't find it too difficult to implement it myself, but I guess every bit of convenience/bug avoidance helps.

Yes, it is a good fit when a customer is supposed to use some functionality one has implemented but shall not see the implementation.