From 7fcf994a00a2e0acf540d66dfc675333ebdefa0e Mon Sep 17 00:00:00 2001 From: Akash Mozumdar Date: Wed, 23 Jan 2019 14:47:42 -0500 Subject: [PATCH] more reliable op phandle --- include/types.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/types.h b/include/types.h index c5526b6..36fa387 100644 --- a/include/types.h +++ b/include/types.h @@ -39,11 +39,11 @@ class AutoHandle public: AutoHandle(HANDLE h) : h(h) {} operator HANDLE() { return h.get(); } - PHANDLE operator&() { return &h._Myptr(); } + PHANDLE operator&() { static_assert(sizeof(*this) == sizeof(HANDLE)); return (PHANDLE)this; } operator bool() { return h.get() != NULL && h.get() != INVALID_HANDLE_VALUE; } private: - struct HandleCleaner : HandleCloser { void operator()(void* h) { if (h != INVALID_HANDLE_VALUE) HandleCloser::operator()(h); } }; + struct HandleCleaner { void operator()(void* h) { if (h != INVALID_HANDLE_VALUE) HandleCloser()(h); } }; std::unique_ptr h; };