diff --git a/include/WinStd/Common.h b/include/WinStd/Common.h index 78cce066..5b5d9980 100644 --- a/include/WinStd/Common.h +++ b/include/WinStd/Common.h @@ -196,6 +196,62 @@ namespace winstd #endif + /// + /// Deleter for unique_ptr using LocalFree + /// + template struct LocalFree_delete + { + typedef LocalFree_delete<_Ty> _Myt; + + /// + /// Default construct + /// + LocalFree_delete() {} + + /// + /// Construct from another LocalFree_delete + /// + template LocalFree_delete(const LocalFree_delete<_Ty2>&) {} + + /// + /// Delete a pointer + /// + void operator()(_Ty *_Ptr) const + { + LocalFree(_Ptr); + } + }; + + /// + /// Deleter for unique_ptr to array of unknown size using LocalFree + /// + template struct LocalFree_delete<_Ty[]> + { + typedef LocalFree_delete<_Ty> _Myt; + + /// + /// Default construct + /// + LocalFree_delete() {} + + /// + /// Delete a pointer + /// + void operator()(_Ty *_Ptr) const + { + LocalFree(_Ptr); + } + + /// + /// Delete a pointer of another type + /// + template + void operator()(_Other *) const + { + LocalFree(_Ptr); + } + }; + /// /// \defgroup WinStdSysHandles System Handles /// Simplifies work with object handles of various type