Encapsulate each resource in a class that clears them in its destructor (with the surrounding try / catch):
struct ProperlyManagedA {
A shared_ptr with user deletion is one way to achieve this without having to create an entire class for each type of resource.
You can improve the disabling of exceptions (for example, the problem log), depending on what is selected.
Better yet, modify the resources of A, B, and C so that they are cleaned up in their own destructors. However, this may not be possible.
In any case, you can place as many resources in one class as you want, without adding any code to the class destructor. This is scalability. The whole point of RAII is that each resource user does not need to write a cleanup code in order to properly use the resource.
Steve jessop
source share