aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/handle.hpp
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2016-09-16 01:47:56 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2016-09-16 01:47:56 +0300
commitfbd6445c68745d484d5df8c75b0c12054185958f (patch)
treec8eb6da6b89d88f530647f408fd2c47669e1bb27 /handle.hpp
parent.hpp instead of .h for C++ headers (diff)
downloadprivilege-check-fbd6445c68745d484d5df8c75b0c12054185958f.tar.gz
privilege-check-fbd6445c68745d484d5df8c75b0c12054185958f.zip
move source files to src/
Diffstat (limited to 'handle.hpp')
-rw-r--r--handle.hpp64
1 files changed, 0 insertions, 64 deletions
diff --git a/handle.hpp b/handle.hpp
deleted file mode 100644
index 5f83f24..0000000
--- a/handle.hpp
+++ /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);
- }
-}