Skip to content

Commit ac79b00

Browse files
author
Donatien Garnier
committed
Cleanup description
1 parent 2608478 commit ac79b00

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

platform/SharedPtr.h

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,31 +32,33 @@
3232
* @code
3333
* #include "platform/SharedPtr.h"
3434
*
35-
* struct MyStruct { int a; };
35+
* void test() {
36+
* struct MyStruct { int a; };
3637
*
37-
* // Create shared pointer
38-
* SharedPtr<MyStruct> ptr( new MyStruct );
38+
* // Create shared pointer
39+
* SharedPtr<MyStruct> ptr( new MyStruct );
3940
*
40-
* // Increase reference count
41-
* SharedPtr<MyStruct> ptr2( ptr );
41+
* // Increase reference count
42+
* SharedPtr<MyStruct> ptr2( ptr );
4243
*
43-
* ptr = NULL; // Reference to the struct instance is still held by ptr2
44+
* ptr = NULL; // Reference to the struct instance is still held by ptr2
4445
*
45-
* ptr2 = NULL; // The raw pointer is freed
46+
* ptr2 = NULL; // The raw pointer is freed
47+
* }
4648
* @endcode
4749
*
4850
*
4951
* It is similar to the std::shared_ptr class introduced in C++11,
5052
* however this is not a compatible implementation (no weak pointer, no make_shared, no custom deleters, etc.)
5153
*
52-
* Usage: SharedPtr<class> POINTER(new class())
54+
* Usage: SharedPtr<Class> ptr(new Class())
5355
*
54-
* When POINTER is passed around by value the copy constructor and
55-
* destructor counts the number of references to the original object.
56-
* If the counter reaches zero, delete is called on the object pointed to.
56+
* When ptr is passed around by value the copy constructor and
57+
* destructor manages the reference count of the raw pointer.
58+
* If the counter reaches zero, delete is called on the raw pointer.
5759
*
5860
* To avoid loops, "weak" references should be used by calling the original
59-
* pointer directly through POINTER.get().
61+
* pointer directly through ptr.get().
6062
*/
6163

6264
template <class T>

0 commit comments

Comments
 (0)