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)
77 if (m_ResourcePtr && m_CloseFunc)
78 m_CloseFunc(m_ResourcePtr);
82 #define CPL_AUTO_CLOSE_WARP(hObject, closeFunc) \
83 CPLAutoClose<decltype(hObject), decltype(closeFunc) *> \
84 tAutoClose##hObject(hObject, closeFunc)