pImpl Idiom

Hey,

I might be asking this because of a lack of experience.

What is the point of using the pImpl idiom when you are just going to forward the the calls of the handle class to the same functions in the Impl class ? Isn't that unnecessary indirection ?

note : I'm not an experienced user, so If I'm missing I'd be happy if you educate me.

Thanks in advance.
1) Separating implementation and interface, increasing encapsulation. With common approach you will see non-public members. With PIMPL you will see a single [smart]pointer to class whose definition you don't see and public methods of containing class.

2) Lessening objects size (almost always the size of [smart]pointer) and making sure that fast move operation will be avaliable.

3) Ability to use value semantic with polymorphism.
Topic archived. No new replies allowed.