Format all the code

This commit is contained in:
momo5502
2025-01-06 17:13:33 +01:00
parent 64c2a79f0f
commit bff8420ffd
100 changed files with 16439 additions and 14509 deletions

View File

@@ -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