Simplify UnmapViewOfFile_delete

No need to have it as a template. And array version is not required
either.
This commit is contained in:
Simon Rozman 2023-12-08 14:23:26 +01:00
parent f778e698c9
commit e2a279f30f

View File

@ -1135,56 +1135,12 @@ namespace winstd
/// ///
/// Deleter for unique_ptr using UnmapViewOfFile /// Deleter for unique_ptr using UnmapViewOfFile
/// ///
template <class _Ty> struct UnmapViewOfFile_delete struct UnmapViewOfFile_delete
{ {
typedef UnmapViewOfFile_delete<_Ty> _Myt; ///< This type
///
/// Default construct
///
UnmapViewOfFile_delete() {}
///
/// Construct from another UnmapViewOfFile_delete
///
template <class _Ty2> UnmapViewOfFile_delete(const UnmapViewOfFile_delete<_Ty2>&) {}
/// ///
/// Delete a pointer /// Delete a pointer
/// ///
void operator()(_Ty* _Ptr) const void operator()(void* _Ptr) const
{
if (!UnmapViewOfFile(_Ptr))
throw win_runtime_error("UnmapViewOfFile failed");
}
};
///
/// Deleter for unique_ptr to array of unknown size using UnmapViewOfFile
///
template <class _Ty> struct UnmapViewOfFile_delete<_Ty[]>
{
typedef UnmapViewOfFile_delete<_Ty> _Myt; ///< This type
///
/// Default construct
///
UnmapViewOfFile_delete() {}
///
/// Delete a pointer
///
void operator()(_Ty* _Ptr) const
{
if (!UnmapViewOfFile(_Ptr))
throw win_runtime_error("UnmapViewOfFile failed");
}
///
/// Delete a pointer of another type
///
template<class _Other>
void operator()(_Other*) const
{ {
if (!UnmapViewOfFile(_Ptr)) if (!UnmapViewOfFile(_Ptr))
throw win_runtime_error("UnmapViewOfFile failed"); throw win_runtime_error("UnmapViewOfFile failed");