Smart Pointers: Difference between revisions
Jump to navigation
Jump to search
(Cleanup) |
(adds context on the existence of QPointer) |
||
Line 7: | Line 7: | ||
== Smart Pointers in Qt == | == Smart Pointers in Qt == | ||
* {{DocLink|QSharedDataPointer}} | * {{DocLink|QSharedDataPointer}} | ||
* {{DocLink|QExplicitlySharedDataPointer}} | * {{DocLink|QExplicitlySharedDataPointer}} | ||
Line 13: | Line 12: | ||
* {{DocLink|QSharedPointer}} | * {{DocLink|QSharedPointer}} | ||
* {{DocLink|QWeakPointer}} | * {{DocLink|QWeakPointer}} | ||
* {{DocLink|QPointer}} since Qt5 a wrapper around QWeakPointer. The class was once planned to be deprecated but instead was kept to support legacy code. | |||
* QGuard (internal class) | * QGuard (internal class) | ||
* {{DocLink|QScopedPointer}} | * {{DocLink|QScopedPointer}} | ||
Line 19: | Line 19: | ||
== See also == | == See also == | ||
[http://blog.qt.io/blog/2009/08/25/count-with-me-how-many-smart-pointer-classes-does-qt-have/ Count with me: how many smart pointer classes does Qt have?] | * [http://blog.qt.io/blog/2009/08/25/count-with-me-how-many-smart-pointer-classes-does-qt-have/ Count with me: how many smart pointer classes does Qt have?] | ||
* [http://www.macieira.org/blog/2012/07/continue-using-qpointer/ Continue using QPointer] | |||
== References == | == References == | ||
[http://en.wikipedia.org/wiki/Smart_pointers Smart Pointer] | [http://en.wikipedia.org/wiki/Smart_pointers Smart Pointer] |
Latest revision as of 16:54, 3 November 2017
Purpose
A smart pointer is an abstract data type that has all features of a standard pointer and additionally provides automatic garbage collection. Smart pointers facilitate the dynamic memory operations. Their main advantage is reducing memory leaks and bugs due to poor memory management.
Smart Pointers in Qt
- QSharedDataPointer
- QExplicitlySharedDataPointer
- QtPatternist::AutoPtr (internal class)
- QSharedPointer
- QWeakPointer
- QPointer since Qt5 a wrapper around QWeakPointer. The class was once planned to be deprecated but instead was kept to support legacy code.
- QGuard (internal class)
- QScopedPointer
- QScopedArrayPointer