31 #ifndef CPL_AUTO_CLOSE_H_INCLUDED
32 #define CPL_AUTO_CLOSE_H_INCLUDED
34 #if defined(__cplusplus)
35 #include <type_traits>
51 static_assert(!std::is_const<_Ty>::value && std::is_pointer<_Ty>::value,
52 "_Ty must is pointer type,_Dx must is function type");
69 : m_ResourcePtr(ptr), m_CloseFunc(dt)
78 if (m_ResourcePtr && m_CloseFunc)
79 m_CloseFunc(m_ResourcePtr);
83 #define CPL_AUTO_CLOSE_WARP(hObject, closeFunc) \
84 CPLAutoClose<decltype(hObject), decltype(closeFunc) *> \
85 tAutoClose##hObject(hObject, closeFunc)
The class use the destructor to automatically close the resource.
Definition: cpl_auto_close.h:50
CPLAutoClose(_Ty &ptr, _Dx dt)
Constructor.
Definition: cpl_auto_close.h:68
~CPLAutoClose()
Destructor.
Definition: cpl_auto_close.h:76