From 8a724eb7727fa797bce78de6c8af86ba0fe610e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=B6eh=20Matt?= <3397065-ZehMatt@users.noreply.gitlab.com> Date: Mon, 18 Jul 2022 22:28:35 +0300 Subject: [PATCH] Delete assignment and copy constructor --- components/platform/file.hpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/components/platform/file.hpp b/components/platform/file.hpp index bd22394197..ae803edb22 100644 --- a/components/platform/file.hpp +++ b/components/platform/file.hpp @@ -34,8 +34,21 @@ namespace Platform::File { Handle mHandle{ Handle::Invalid }; public: - ScopedHandle() = default; - ScopedHandle(Handle handle) : mHandle(handle) {} + ScopedHandle() noexcept = default; + ScopedHandle(ScopedHandle& other) = delete; + ScopedHandle(Handle handle) noexcept : mHandle(handle) {} + ScopedHandle(ScopedHandle&& other) noexcept + : mHandle(other.mHandle) + { + other.mHandle = Handle::Invalid; + } + ScopedHandle& operator=(const ScopedHandle& other) = delete; + ScopedHandle& operator=(ScopedHandle&& other) noexcept + { + mHandle = other.mHandle; + other.mHandle = Handle::Invalid; + return *this; + } ~ScopedHandle() { if(mHandle != Handle::Invalid)