
On 04/17/2011 07:10 PM, Clinton Mead wrote:
And if Klass is the interface, won't it need to contain another pointer, which would result in following two pointers instead of one for all method calls?
Who cares? It's a reasonable price for what Pimpl buys you. The price of that encapsulation is a little indirection. With the added benefit that it can be used as a plain old value type (no pointer, except the one hidden inside). If that cost is too much to bear, Pimpl isn't the right answer in the first place. I think you might be missing the point about why Pimpl is such a rockin' cool idea. It is an extremely simple mechanism for ensuring ABI stability. If it's no longer dead simple, it completely loses its charm; it becomes harder to maintain a stable ABI. Library writers don't want that.