31 #ifndef CPL_AUTO_CLOSE_H_INCLUDED
32 #define CPL_AUTO_CLOSE_H_INCLUDED
34 #if defined(__cplusplus)
35 #include <type_traits>
50 template<
typename _Ty,
typename _Dx>
52 static_assert( !std::is_const<_Ty>::value && std::is_pointer<_Ty>::value,
53 "_Ty must is pointer type,_Dx must is function type");
58 CPLAutoClose(
const CPLAutoClose&) =
delete;
59 void operator=(
const CPLAutoClose&) =
delete;
66 explicit CPLAutoClose(_Ty& ptr,_Dx dt) :
75 if(m_ResourcePtr && m_CloseFunc)
76 m_CloseFunc(m_ResourcePtr);
80 #define CPL_AUTO_CLOSE_WARP(hObject,closeFunc) \
81 CPLAutoClose<decltype(hObject),decltype(closeFunc)*> tAutoClose##hObject(hObject,closeFunc)