Skip to content

Commit

Permalink
Simplify UnmapViewOfFile_delete
Browse files Browse the repository at this point in the history
No need to have it as a template. And array version is not required
either.
  • Loading branch information
rozmansi committed Dec 8, 2023
1 parent f778e69 commit e2a279f
Showing 1 changed file with 2 additions and 46 deletions.
48 changes: 2 additions & 46 deletions include/WinStd/Win.h
Original file line number Diff line number Diff line change
Expand Up @@ -1135,56 +1135,12 @@ namespace winstd
///
/// 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
///
void operator()(_Ty* _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
void operator()(void* _Ptr) const
{
if (!UnmapViewOfFile(_Ptr))
throw win_runtime_error("UnmapViewOfFile failed");
Expand Down

0 comments on commit e2a279f

Please sign in to comment.