c++ auto_ptr garbage collection try catch throw with source for autoDelete
june 20 2014 see text bubbles in video for corrections .
I started using an enhanced use concept with auto_ptr , but auto_ptr is not flexible enough. So I wrote autoDelete class .
3 source code files in the video main.h man.cpp autoDelete.h
Place autoDelete.h into your normal Include folder of header
files and autoDelete is ready for use, to allocate 1D 2D 3D
arrays all with automatic garbage collection, and we continue to
use a regualr c\c++ pointer to access the heap items, so we get full speed of c\c++ ,. no double de-referencing needed.
autoDelete is NOT a smart pointer . autoDelete is more of an
allocator class that provides automatic garbage collection.
I describe it's use by providing the source code.
main.cpp shows how to use it. I compiled as x64 release .
exception handling try catch throw included .
catch(...) can get bypassed by unexpected() or directly by terminate( ) . The order of calls is:
unexpected( ) calls terminate( ) and terminate( ) calls abort( )
a throw that is NOT in a "throw list" calls unexpected( )
a throw that occures outside of a try block or a throw that is NOT
caught( ) causes a direct call to terminate( ) .
unexpected( ) always calls terminate( ) , and terminate( ) always calls abort( ) .
we can Trap to delegate by using set_unexpected( ) and set_terminate( ) , however, abort( ) will still get called .
The function( ) pointers can only be "c" style . .
abort( ) does NOT allow ~destructors to run .
So, if unexpected( ) or terminate() are CALL'd , we might be
able to Free heap allocations there, with our custom delegate
function( ) . I have had commercial\paid for programs crash with
abort( )\unknown error , and it's best to re-boot no matter what .
unexpected( ) and terminate( ) can be fixed in the source.
remove "throw List" constraints . Place ALL throws from inside a try block . Make any\all legitimate throws to have a matching catch( ) block .