mirror of
https://github.com/Artikash/Textractor.git
synced 2024-12-23 17:04:12 +08:00
more reliable op phandle
This commit is contained in:
parent
632139dce2
commit
7fcf994a00
@ -39,11 +39,11 @@ class AutoHandle
|
|||||||
public:
|
public:
|
||||||
AutoHandle(HANDLE h) : h(h) {}
|
AutoHandle(HANDLE h) : h(h) {}
|
||||||
operator HANDLE() { return h.get(); }
|
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; }
|
operator bool() { return h.get() != NULL && h.get() != INVALID_HANDLE_VALUE; }
|
||||||
|
|
||||||
private:
|
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<void, HandleCleaner> h;
|
std::unique_ptr<void, HandleCleaner> h;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user