On Thursday 22 August 2013 12:44:41 Ivan Čukić wrote: > Hi all, > > Keep forgetting to write this mail for a while now. It is intended mostly > for (in aplhabetical order) Aaron, Marco, Martin and Sebastian, but > everybody is invited to chime in. > > It is about the smart and safe d-pointer I have presented some time ago [1]. > > The question is should it be used in plasma and where? > > Cons: > - too low level to be in plasma-frameworks (sebas) > - none else that I know of
Well, I can add one more. They use variadic templates which are not in the list of C++11 features which can be used unconditionally in plasma-framework. Can be spared if you loose the forwarded constructor arguments though. > Pros: > - safety: no access to the raw pointer > - safety: no accidental initialization errors or anything similar > - safety: no possible leaks > - convenience: forwarded constructor arguments (': d(1,2)' instead of ': > d(new Private(1,2))') > - convenience: default constructor works for no-arg Private constructor > (nothing instead of 'd(new Private())') > - convenience: no delete d; > - they are spiffy (aaron) :) > > Choices: > 1. (a non-choice imo) Use raw pointers like in the old days everywhere > 2. Use less safe and less convenient smart-pointers like std::unique_ptr or > QScopedPointer > 3. Use this d-ptr outside of the library, choose 1 or 2 for the library > 4. Use it everywhere, but export the headers as if it were 1 or 2 (all > should be binary compatible with a raw pointer) > 5. Use it everywhere, and install the header file for the users to be able > to use it as well. (it is a templated class, so it leaves no binary > footprint by itself) > > Cheerio, > Ivan > > [1] http://ivan.fomentgroup.org/blog/2013/06/22/d-ptr-the-modern-way/ Regards. -- Kévin Ottens, http://ervin.ipsquad.net KDAB - proud supporter of KDE, http://www.kdab.com
signature.asc
Description: This is a digitally signed message part.
_______________________________________________ Plasma-devel mailing list Plasma-devel@kde.org https://mail.kde.org/mailman/listinfo/plasma-devel