Difference between revisions of "Spec:o3tl/utilities/heap ptr"
From Apache OpenOffice Wiki
(→References: removing empty lines) |
(removing empty fields) |
||
Line 62: | Line 62: | ||
| n/a | | n/a | ||
| n/a | | n/a | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
|- | |- | ||
|} | |} | ||
Line 83: | Line 73: | ||
;RAII in function bodies:It can be used in new code, when using RAII for heap memory within a function body. | ;RAII in function bodies:It can be used in new code, when using RAII for heap memory within a function body. | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
== Open Issues == | == Open Issues == |
Revision as of 08:18, 11 July 2007
o3tl::heap_ptr<> - a Const-Transitive Smart Pointer Class
Specification Status | |
Author | Nikolai Pretzell |
Last Change | 2007-05-15 |
Status | Preliminary |
Abstract
heap_ptr<>
is a const-transitive, non-copyable, C++ smart pointer class.
- smart pointer: A class that holds a pointer to memory allocated on the heap. The destructor automatically deletes (deallocates) the memory.
- const-transitive: In
const heap_ptr<int> pX( new int(25) );
not only pX is const, but also the integer value it points to. This is useful for member variables of classes, because if the class administrates the heap memory, it is normally part of its state. - non-copyable: When copying pointers to heap-memory, there either must be a reference counting or the pointer must not be copyable to make sure, delete is called at the right time for the heap memory.
References
Reference Document | Location (URL) |
Product Requirement, RFE, Issue ID | IssueZilla 76768 |
Test case specification | Unit Tests in module o3tl/qa/test-heap_ptr.cxx |
Coding Standards this class helps to match | http://wiki.services.openoffice.org/wiki/Cpp_Coding_Standards/GEN#RAII |
Contacts
Role | Name | E-Mail Address |
Developer | Nikolai Pretzell | np@openoffice.org |
Quality Assurance | Thorsten Behrens | thb@openoffice.org |
Documentation | Nikolai Pretzell | np@openoffice.org |
User Experience | n/a | n/a |
Detailed Specification
TBD
Migration
- Member data on the heap
- This class should be the default for class members that are pointers to heap memory and are not shared with other instances, but administrated only by one object. Plain pointers, std::auto_ptr<> and non const-transitive pointers should be replaced, when refactoring.
- RAII in function bodies
- It can be used in new code, when using RAII for heap memory within a function body.
Open Issues
-