ItalaApi  1.3.3
Smart.h File Reference

Go to the source code of this file.

Detailed Description

The following functions provide a convenient way for managing IDisposable instances lifecycle via the smart pointers of the C++ standard library. These functions should be called immediately after creating the instance to avoid both raw and smart pointers around at the same time. When the smart pointer is destroyed, the IDisposable::Dispose method of the IDisposable interface is automatically called.

{
// here the system instance is created and passed to a smart pointer
Itala::SystemPtr pSystem = Itala::SmartAssign(Itala::CreateSystem());
} // here the system instance is automatically disposed as the pointer goes out of scope
Warning
When a IDisposable instance is owned by a smart pointer, its IDisposable::Dispose method must NEVER be called manually!

Note that this header is just a quick helper completely editable by the user. Feel free to introduce improvements or entirely swap the smart pointer implementation with a different one (e.g. Boost).