diff options
| author | Egor Tensin <egor@tensin.name> | 2026-06-13 00:36:59 +0200 |
|---|---|---|
| committer | Egor Tensin <egor@tensin.name> | 2026-06-13 00:39:55 +0200 |
| commit | 190ff781eaee33e7a61aab44fc4133718cc0515b (patch) | |
| tree | 469cedfc87734589a4e9a0102f69324b9edb8f16 /src/handle.hpp | |
| parent | cmake: upgrade minimum version (diff) | |
| download | privilege-check-190ff781eaee33e7a61aab44fc4133718cc0515b.tar.gz privilege-check-190ff781eaee33e7a61aab44fc4133718cc0515b.zip | |
add .clang-format
Diffstat (limited to 'src/handle.hpp')
| -rw-r--r-- | src/handle.hpp | 45 |
1 files changed, 17 insertions, 28 deletions
diff --git a/src/handle.hpp b/src/handle.hpp index 4bc0a97..5839594 100644 --- a/src/handle.hpp +++ b/src/handle.hpp @@ -8,51 +8,41 @@ #include <windows.h> #include <cassert> - #include <memory> #include <utility> -class Handle -{ +class Handle { public: Handle() = default; - explicit Handle(HANDLE raw) - : impl{raw} - { } + explicit Handle(HANDLE raw) : impl{raw} {} - Handle(Handle&& other) noexcept - { + Handle(Handle&& other) noexcept { swap(other); } - Handle& operator=(Handle other) noexcept - { + Handle& operator=(Handle other) noexcept { swap(other); return *this; } - void swap(Handle& other) noexcept - { + void swap(Handle& other) noexcept { using std::swap; swap(impl, other.impl); } - operator HANDLE() const - { + operator HANDLE() const { return impl.get(); } private: - struct Close - { - void operator()(HANDLE raw) const - { + struct Close { + void operator()(HANDLE raw) const { if (raw == NULL || raw == INVALID_HANDLE_VALUE) return; const auto ret = CloseHandle(raw); assert(ret); - (void) ret; + (void)ret; } }; @@ -61,16 +51,15 @@ private: Handle(const Handle&) = delete; }; -inline void swap(Handle& a, Handle& b) noexcept -{ +inline void swap(Handle& a, Handle& b) noexcept { a.swap(b); } -namespace std -{ - template <> - inline void swap(Handle& a, Handle& b) noexcept - { - a.swap(b); - } +namespace std { + +template <> +inline void swap(Handle& a, Handle& b) noexcept { + a.swap(b); } + +} // namespace std |
