Pimpl copying
Thiago Macieira
thiago at kde.org
Tue Jul 18 19:28:08 BST 2006
Peter Kümmel wrote:
>#define Q_DECLARE_PRIVATE(Class) \
> inline Class##Private* d_func() { return
> reinterpret_cast<Class##Private *>(d_ptr); } \ inline const
> Class##Private* d_func() const { return reinterpret_cast<const
> Class##Private *>(d_ptr); } \ friend class Class##Private;
>
>#define Q_D(Class) Class##Private * const d = d_func()
>
>
>So you get a 'const ClassPrivate*' when you call d_func() in a const
> function, seems I was wrong.
const Q_D(MyClass);
ugly, but it works.
Then again, most const functions don't do much and could just use
return d_func()->value;
>BTW the cast is the price they pay for their Private "Hinterwelt", means
> there is a second class hierarchy behind the scene.
Correct :-)
--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
PGP/GPG: 0x6EF45358; fingerprint:
E067 918B B660 DBD1 105C 966C 33F5 F005 6EF4 5358
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20060718/6433919d/attachment.sig>
More information about the kde-core-devel
mailing list