The idea of this class is to manage resources which the current code is responsible for freeing. By wrapping the resource in an RTAutoRes, you ensure that the resource will be freed when you leave the scope in which the RTAutoRes is defined, unless you explicitly release the resource.
A typical use case is when a function is allocating a number of resources. If any single allocation fails then all other resources must be freed. If all allocations succeed, then the resources should be returned to the caller. By placing all allocated resources in RTAutoRes containers, you ensure that they will be freed on failure, and only have to take care of releasing them when you return them.
|T||The type of the resource.|
|Destruct||The function to be used to free the resource. This parameter must be supplied if there is no specialisation of RTAutoDestruct available for T.|
|NilRes||The function returning the NIL value for T. Required. This parameter must be supplied if there is no specialisation of RTAutoResNil available for T.|
Public Member Functions
|RTAutoRes &||operator= (T a_hRes)|
|void||reset (T a_hRes=NilRes())|
|RTAutoRes (T a_hRes=NilRes())|