-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathWinUtils.h
More file actions
27 lines (21 loc) · 817 Bytes
/
WinUtils.h
File metadata and controls
27 lines (21 loc) · 817 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#pragma once
class WinHandle
{
public:
WinHandle(HANDLE value = NULL) : value_(value) {}
operator HANDLE() const { return value_; }
friend bool operator ==(WinHandle l, WinHandle r) { return l.value_ == r.value_; }
friend bool operator !=(WinHandle l, WinHandle r) { return l.value_ != r.value_; }
friend bool operator ==(HANDLE l, WinHandle r) { return l == r.value_; }
friend bool operator !=(HANDLE l, WinHandle r) { return l != r.value_; }
friend bool operator ==(WinHandle l, HANDLE r) { return l.value_ == r; }
friend bool operator !=(WinHandle l, HANDLE r) { return l.value_ != r; }
struct Deleter
{
typedef WinHandle pointer;
void operator()(WinHandle handle) const { CloseHandle(handle); }
};
private:
HANDLE value_;
};
typedef std::unique_ptr<WinHandle, WinHandle::Deleter> HandlePtr;