Heise Developer: Pimp My Pimpl (part 1)
2010-10-05 7 Comments
For you German speakers out there, my second Heise Developer article, “Pimp my Pimpl: Vor- und Nachteile des d-Zeiger-Idioms, Teil 1“, just went live on Heise’s site.
[[EDIT 2011-04-16: An English version is now available]
It’s part one of a two-part article focusing on the advantages and disadvantages of the pimpl idiom.
From the article:
Als bekanntes C++-Idiom erlaubt Pimpl es dem Klassenautor, die Schnittstelle von der Implementierung einer Klasse in einem Maße zu trennen, wie das in C++ eigentlich nicht vorgesehen ist. Als positiver Nebeneffekt beschleunigt der Einsatz von d-Zeigern Übersetzungsläufe, erleichtert die Implementierung von Transaktionssemantik und erlaubt durch erweiterte Mittel der Komposition mitunter zur Laufzeit effizientere Implementierungen.
Nicht alles ist jedoch gut beim Einsatz von d-Zeigern: Neben der zusätzlichen Private-Klasse und deren dynamischer Speicheranforderung bereiten die geänderte const-Methoden-Semantik und Allokationssequenzfehler Sorgen.

Can we count on English translation of your article?
Yes, I have obtained permission to publish an English version on this blog. It will happen sometime during December, probably.
Really interesting to read. I would like to know if this way of accessing variables makes any difference in speed if I use this for CPU consuming calculations, where the variable access is made via pimpl idiom.
Not long ago someone told me that in his company this would not be used because of the decrease in speed in algorithms.
Yeah, it’s a trade-off, as usual. If you have simple data classes, then pimpl produces noticeable overhead (not only through the indirection, but also because you can’t have inline functions anymore). If you can, moving the function onto the
Privateclass is one option to get some speed back.When is the second part of the article due? I can’t wait!
Probably next week.
Pingback: Translated: Pimp My Pimpl (part 1) « -Wmarc