Smart D-Ptr in KCoreAddons
Ivan Čukić
ivan.cukic at kde.org
Fri Aug 23 10:06:38 UTC 2013
> I honestly don't see what it actually brings us over using
> QScopedPointer. It gives safety and convenience - and they are actually
> also spiffy.
QSP is as spiffy as a unique_ptr:
> std::unique_ptr with make_unique does not provide P1, P2, P5 and P4.
> P1 - safety: no access to the raw pointer
> P2 - safety: no accidental initialization errors or anything similar
> P3 - safety: no possible leaks
> P4 - convenience: forwarded constructor arguments (': d(1,2)' instead of ':
> d(new Private(1,2))')
> P5 - convenience: default constructor works for no-arg Private constructor
> (nothing instead of 'd(new Private())')
> P6 - convenience: no delete d;
> P7 - they are spiffy (Aaron)
> oh. and I think it also looks a bit like your d-ptr gets in the way when
> you need a d-ptr hierachy.
As I said, this is for non-inherited privates.
Cheers,
Ivan
--
When the pupil is ready to learn, a teacher will appear.
-- Basho
More information about the Kde-frameworks-devel
mailing list