QSharedPointer 和 QSharedDataPointer 之间的区别?
这两种类型的指针有什么区别?据我所知,QSharedPointer可以很好地处理这种情况,那么QSharedDataPointer需要什么?
What is the difference between these two types of pointers? As far as I can read, QSharedPointer can handle situation well, so what is the need for QSharedDataPointer?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
来自 Qt 文档
QSharedDataPointer
用法示例 -
对于 QSharedPointer
因此,QSharedDataPointer 用于创建隐式共享类。而 QSharedPointer 是一个指向类的引用计数智能指针。
编辑
在阅读Qt中的内存管理?时,我找到了此链接http://blog.qt.io/blog/2009/08/25/count-with-me-how-many-smart-pointer-classes-does-qt-have/。关于 Qt 不同智能指针的非常精彩的讨论(当前 API 有 8 个)。
From Qt documentation
QSharedDataPointer
Example usage -
For QSharedPointer
So, the QSharedDataPointer is used to make creating implicititly shared classes. Whereas QSharedPointer is a reference counting Smart pointer that points to classes.
EDIT
When reading Memory management in Qt?, I found this link http://blog.qt.io/blog/2009/08/25/count-with-me-how-many-smart-pointer-classes-does-qt-have/. A really excellent discussion of the different smart pointers Qt has (current API has 8).