Smart d-ptr in Plasma

Ivan Čukić ivan.cukic at kde.org
Thu Aug 22 10:44:41 UTC 2013


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

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/


-- 
Science gathers knowledge faster than society gathers wisdom.
  -- Isaac Asimov



More information about the Plasma-devel mailing list