--nextPart1996094.nOCXa599mf Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline > Attached a proposal for a different implementation of the Pimpl idiom, > which has not above problems. > > It automatically creates on construction, and deletes on destruction the > private implementation object, it also propagates the constness to the > private object. > It is pure C++ and needs no macros or static variables. Yes, and since it uses no macros, it doesn't support the Derived::Private : public Base::Private optimization found in Qt4... I've been through three iterations of a=20 KDAB::pimpl_ptr of mine, as well as - just now, actually - through the=20 implementation of boost::pimpl_ptr (pending boost review atm), and none of= =20 these make it any more easy to implement Derived than a pale pointer (meani= ng=20 you still need about the same amount of macros as before. I e.g. use a macr= o=20 to generate the ctors and dtors, too, so delete pimpl can't be forgotten). OTOH, there's Q_D and Q_Q and all the declaration macros, and as much as I= =20 despise them for requiring an extra line of code in _every_ member function= ,=20 they are there, and obviously work (Q_D and Q_Q could be made to go away by= =20 saying #define d d_func() #define q q_func() in the .cpp file, which is wha= t=20 I use in KDAB projects. It prevents you from having a variable or parameter= =20 'd' or 'q', but the use of a naked 'd'-pointer together with a parameter 'd= '=20 triggers what others so fondly call -Wmarc anyway (-Wshadow for gcc), so it= =20 isn't much of a problem in practice). Using Q_* macros also makes it easier to derive from QObjectPrivate. The on= ly=20 price we had to pay for that would be to have to recomplile kdelibs when Qt= =20 is changed. Shrug. Has anyone ever used this? Maybe. Has it ever worked=20 reliably? Only after explicit fixing in kdelibs. Thanks, Marc --nextPart1996094.nOCXa599mf Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2 (GNU/Linux) iD8DBQBD8EYU3oWD+L2/6DgRAjGIAJ4ouKG1vIivK38cfG6C6BOFtn759ACg4AlN NxccE6uLbChOzk49Q8NXwXQ= =VcvF -----END PGP SIGNATURE----- --nextPart1996094.nOCXa599mf--