14#ifndef CPL_AUTO_CLOSE_H_INCLUDED
15#define CPL_AUTO_CLOSE_H_INCLUDED
17#if defined(__cplusplus)
34 static_assert(!std::is_const<_Ty>::value && std::is_pointer<_Ty>::value,
35 "_Ty must is pointer type,_Dx must is function type");
52 : m_ResourcePtr(ptr), m_CloseFunc(dt)
61 if (m_ResourcePtr && m_CloseFunc)
62 m_CloseFunc(m_ResourcePtr);
66#define CPL_AUTO_CLOSE_WARP(hObject, closeFunc) \
67 CPLAutoClose<decltype(hObject), decltype(closeFunc) *> \
68 tAutoClose##hObject(hObject, closeFunc)
The class use the destructor to automatically close the resource.
Definition cpl_auto_close.h:33
CPLAutoClose(_Ty &ptr, _Dx dt)
Constructor.
Definition cpl_auto_close.h:51
~CPLAutoClose()
Destructor.
Definition cpl_auto_close.h:59