Qxt是一个Qt的扩展库。其中也用到了d-pointer技术,但是与Qt的区别很大,比起Qt有点不足之处。这里我先简单看下它的实现,然后吸取Qt中的优点进行改进。(最新代码在 https://github.com/wang-bin/d-pointer )
之前写过一篇关于d-pointer的文章 http://blog.csdn.net/ibingow/article/details/7522157 ,这里很多细节就不重复了。
在qxtglobal.h中相关代码
/****************************************************************************
** This file is derived from code bearing the following notice:
** The sole author of this file, Adam Higerd, has explicitly disclaimed all
** copyright interest and protection for the content within. This file has
** been placed in the public domain according to United States copyright
** statute and case law. In jurisdictions where this public domain dedication
** is not legally recognized, anyone who receives a copy of this file is
** permitted to use, modify, duplicate, and redistribute this file, in whole
** or in part, with no restrictions or conditions. In these jurisdictions,
** this file shall be copyright (C) 2006-2008 by Adam Higerd.
****************************************************************************/
#define QXT_DECLARE_PRIVATE(PUB) friend class PUB##Private; QxtPrivateInterface<PUB, PUB##Private> qxt_d;
#define QXT_DECLARE_PUBLIC(PUB) friend class PUB;
#define QXT_INIT_PRIVATE(P