[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-panel-devel
Subject: Re: Smart d-ptr in Plasma
From: Kevin Ottens <ervin () kde ! org>
Date: 2013-08-22 11:29:05
Message-ID: 8166230.a5KB2nsJuF () wintermute
[Download RAW message or body]
[Attachment #2 (multipart/signed)]
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" (application/pgp-signature)]
_______________________________________________
Plasma-devel mailing list
Plasma-devel@kde.org
https://mail.kde.org/mailman/listinfo/plasma-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic