Den 12-09-2015 kl. 10:19 skrev Till Oliver Knoll: > > Am 11.09.2015 um 19:59 schrieb Matthew Woehlke <mwoehlke.fl...@gmail.com > <mailto:mwoehlke.fl...@gmail.com>>: > >> On 2015-09-11 13:41, Till Oliver Knoll wrote: >>> You can further reduce the "dependency tree" of your sources by >>> making use of the private "d-pointer" pattern (there is a name for >>> it which currently escapes me) >> >> PIMPL? ;-) >> >> https://en.wikipedia.org/wiki/Pimpl > > Exactly :) Even though I had the term "Cheshire Cat" in mind :) (I yet > have to google why that pattern is named after a cat). > > But while we're there, quoting from that article: > > "One type of opaque pointer commonly used in C++ class declarations is > the d-pointer. The d-pointer is the only private data member of the > class and points to an instance of a struct. Named by Arnt Gulbrandsen > <https://en.m.wikipedia.org/w/index.php?title=Arnt_Gulbrandsen&action=edit&redlink=1> > of > Trolltech <https://en.m.wikipedia.org/wiki/Trolltech>, this method > allows class declarations to omit private data members, except for the > d-pointer itself.^[6] > <https://en.m.wikipedia.org/wiki/Pimpl#cite_note-6> The result: (a) > more of the class implementation is hidden from view; (b) adding new > data members to the private struct does not affect binary compatibility; > (c) the header file containing the class declaration only needs to > #include those other files needed for the class interface, rather than > for its implementation. One side benefit is that compilations are faster > because the header file changes less often. The d-pointer is heavily > used in the Qt <https://en.m.wikipedia.org/wiki/Qt_(toolkit)> and KDE > <https://en.m.wikipedia.org/wiki/KDE> libraries."
There is another term used for it as well: Compiler firewall. The d-pointers make it impossible for the compiler to perform a long list of optimizations. I value using d-pointers over raw speed for most cases. But it's one thing to keep in mind if you really have to optimize. Bo Thorsen, Director, Viking Software. -- Viking Software Qt and C++ developers for hire http://www.vikingsoft.eu _______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest