Ask a Question | Search PSRCHIVE: |
Home
|
Reference::HeapTracked Class Reference Determines if the instance was dynamically allocated on the heap. More...
Inheritance diagram for Reference::HeapTracked:
Detailed DescriptionDetermines if the instance was dynamically allocated on the heap. The HeapTracked class overloads operator new in order to store the addresses of instances that have been dynamically allocated on the heap (see the HeapTracked class and the discussion in Item 27 of Scott Meyers, More Effective C++). As the number of objects constructed at any one time will generally be much smaller than the number of objects in existence at the time of deletion, it is more efficient to search the heap addresses during construction and to set the __heap_state attribute accordingly. However, in order to handle the possibility of multiple inheritance, it is necessary for the __is_on_heap method to perform a dynamic cast of the "this" pointer before searching the heap addresses. As this dynamic cast does not work inside the constructor of a virtually inherited class, it is not possible to set the __heap_state attribute during construction. Therefore, in order to improve the efficiency of the __is_on_heap search, it is advised to call the __is_on_heap method as soon as possible after construction of the object. This is done by the Reference::Able::__reference method, which is called by the Reference::To template class when its assigment operator is called. The documentation for this class was generated from the following files:
Generated using doxygen 1.8.17
|