logoalt Hacker News

dvratiltoday at 7:55 AM2 repliesview on HN

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.


Replies

hasleytoday at 12:21 PM

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

zabzonktoday at 8:01 AM

> 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.