Figure 5: Using template class

#include <gcroot.h>

template <typename T>
struct Using : gcroot<T>
{
    Using(T t) :
        gcroot<T>(t)
    {
        // Do nothing
    }

    ~Using()
    {
        T t = operator->();

        if (0 != t)
        {
            static_cast<System::IDisposable*>(t)->Dispose();
        }
    }
};
— End of Figure —