protected d-pointers

Matthias Kretz kretz at kde.org
Thu Feb 7 18:51:39 GMT 2008


On Thursday 07 February 2008, André Wöbbeking wrote:
> On Wednesday 06 February 2008, Matthias Kretz wrote:
> > Hi,
> >
> > I suggest we require kdelibs classes to only use protected d-pointers
> > so that the shared-d-pointer pattern can be used when needed. Once we
> > need to keep BC on Windows we cannot change private members to
> > protected members anymore. So we can still do this now...
>
> If necessary you can add a protected ctor later which takes a pimpl
> pointer, no? This should be BC on all platforms.

Yes.

> Hmm, you would still need access to the pimpl in your sub classes.

#define Q_DECLARE_PRIVATE(Class) inline Class##Private* d_func() { return 
reinterpret_cast<Class##Private *>(d_ptr); }

The derived classes don't store the pointer to the private (which would defeat 
the point of the whole exercise) but simply cast the d_ptr of the base class. 
Therefore d_ptr may not be private (unless you want to declare derived 
classes friends of the base class ;-)).

-- 
________________________________________________________
Matthias Kretz (Germany)                            <><
http://Vir.homelinux.org/
MatthiasKretz at gmx.net, kretz at kde.org,
Matthias.Kretz at urz.uni-heidelberg.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20080207/0c3817b6/attachment.sig>


More information about the kde-core-devel mailing list