mirror of
https://github.com/momo5502/emulator.git
synced 2026-01-24 22:21:03 +00:00
Format all the code
This commit is contained in:
@@ -10,80 +10,80 @@
|
||||
|
||||
namespace utils::nt
|
||||
{
|
||||
using HandleFunction = HANDLE();
|
||||
using HandleFunction = HANDLE();
|
||||
|
||||
inline HANDLE null_handle()
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
inline HANDLE null_handle()
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
inline HANDLE invalid_handle()
|
||||
{
|
||||
return INVALID_HANDLE_VALUE;
|
||||
}
|
||||
inline HANDLE invalid_handle()
|
||||
{
|
||||
return INVALID_HANDLE_VALUE;
|
||||
}
|
||||
|
||||
template <HandleFunction InvalidHandleFunction = null_handle>
|
||||
class handle
|
||||
{
|
||||
public:
|
||||
handle() = default;
|
||||
template <HandleFunction InvalidHandleFunction = null_handle>
|
||||
class handle
|
||||
{
|
||||
public:
|
||||
handle() = default;
|
||||
|
||||
handle(const HANDLE h)
|
||||
: handle_(h)
|
||||
{
|
||||
}
|
||||
handle(const HANDLE h)
|
||||
: handle_(h)
|
||||
{
|
||||
}
|
||||
|
||||
~handle()
|
||||
{
|
||||
if (*this)
|
||||
{
|
||||
CloseHandle(this->handle_);
|
||||
this->handle_ = InvalidHandleFunction();
|
||||
}
|
||||
}
|
||||
~handle()
|
||||
{
|
||||
if (*this)
|
||||
{
|
||||
CloseHandle(this->handle_);
|
||||
this->handle_ = InvalidHandleFunction();
|
||||
}
|
||||
}
|
||||
|
||||
handle(const handle&) = delete;
|
||||
handle& operator=(const handle&) = delete;
|
||||
handle(const handle&) = delete;
|
||||
handle& operator=(const handle&) = delete;
|
||||
|
||||
handle(handle&& obj) noexcept
|
||||
: handle()
|
||||
{
|
||||
this->operator=(std::move(obj));
|
||||
}
|
||||
handle(handle&& obj) noexcept
|
||||
: handle()
|
||||
{
|
||||
this->operator=(std::move(obj));
|
||||
}
|
||||
|
||||
handle& operator=(handle&& obj) noexcept
|
||||
{
|
||||
if (this != &obj)
|
||||
{
|
||||
this->~handle();
|
||||
this->handle_ = obj.handle_;
|
||||
obj.handle_ = InvalidHandleFunction();
|
||||
}
|
||||
handle& operator=(handle&& obj) noexcept
|
||||
{
|
||||
if (this != &obj)
|
||||
{
|
||||
this->~handle();
|
||||
this->handle_ = obj.handle_;
|
||||
obj.handle_ = InvalidHandleFunction();
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
handle& operator=(HANDLE h) noexcept
|
||||
{
|
||||
this->~handle();
|
||||
this->handle_ = h;
|
||||
handle& operator=(HANDLE h) noexcept
|
||||
{
|
||||
this->~handle();
|
||||
this->handle_ = h;
|
||||
|
||||
return *this;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
[[nodiscard]] operator bool() const
|
||||
{
|
||||
return this->handle_ != InvalidHandleFunction();
|
||||
}
|
||||
[[nodiscard]] operator bool() const
|
||||
{
|
||||
return this->handle_ != InvalidHandleFunction();
|
||||
}
|
||||
|
||||
[[nodiscard]] operator HANDLE() const
|
||||
{
|
||||
return this->handle_;
|
||||
}
|
||||
[[nodiscard]] operator HANDLE() const
|
||||
{
|
||||
return this->handle_;
|
||||
}
|
||||
|
||||
private:
|
||||
HANDLE handle_{InvalidHandleFunction()};
|
||||
};
|
||||
private:
|
||||
HANDLE handle_{InvalidHandleFunction()};
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user