aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/handle.h
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2016-09-16 01:08:49 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2016-09-16 01:08:49 +0300
commit42f1ad36ef93c98542f9899ada57bd55396a99f5 (patch)
treed0b10dd617764271db739b608a9d6bfaa63d516b /handle.h
parentmake the 'Elevate' button smaller (diff)
downloadprivilege-check-42f1ad36ef93c98542f9899ada57bd55396a99f5.tar.gz
privilege-check-42f1ad36ef93c98542f9899ada57bd55396a99f5.zip
.hpp instead of .h for C++ headers
Diffstat (limited to 'handle.h')
-rw-r--r--handle.h64
1 files changed, 0 insertions, 64 deletions
diff --git a/handle.h b/handle.h
deleted file mode 100644
index 5f83f24..0000000
--- a/handle.h
+++ /dev/null
@@ -1,64 +0,0 @@
-#pragma once
-
-#include <Windows.h>
-
-#include <cassert>
-
-#include <memory>
-#include <utility>
-
-class Handle
-{
-public:
- Handle() = default;
-
- explicit Handle(HANDLE raw)
- : impl{raw}
- { }
-
- Handle(Handle&& other) noexcept
- {
- swap(other);
- }
-
- Handle& operator=(Handle other) noexcept
- {
- swap(other);
- return *this;
- }
-
- void swap(Handle& other) noexcept
- {
- using std::swap;
- swap(impl, other.impl);
- }
-
- operator HANDLE() const
- {
- return impl.get();
- }
-
-private:
- struct Close
- {
- void operator()(HANDLE raw) const
- {
- if (raw == NULL || raw == INVALID_HANDLE_VALUE)
- return;
- const auto ret = CloseHandle(raw);
- assert(ret);
- }
- };
-
- std::unique_ptr<void, Close> impl;
-
- Handle(const Handle&) = delete;
-};
-
-namespace std
-{
- void swap(Handle& a, Handle& b) noexcept
- {
- a.swap(b);
- }
-}