From 1c16ef2601632e4dcfd96e685d71e192f37f9550 Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Thu, 3 May 2018 23:26:26 -0500 Subject: [PATCH] [ox/std] Remove copy constructor and operator from MallocaPtr --- deps/ox/src/ox/std/new.hpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/deps/ox/src/ox/std/new.hpp b/deps/ox/src/ox/std/new.hpp index b1247946..4562b7aa 100644 --- a/deps/ox/src/ox/std/new.hpp +++ b/deps/ox/src/ox/std/new.hpp @@ -32,7 +32,7 @@ void *operator new(std::size_t, void*) noexcept; */ #if defined(OX_USE_STDLIB) #define ox_malloca(size, Type, ...) ox::MallocaPtr(size, new (size > MallocaStackLimit ? new uint8_t[size] : ox_alloca(size)) Type(__VA_ARGS__)) -#else +#else #define ox_malloca(size, Type, ...) ox::MallocaPtr(size, new (ox_alloca(size)) Type(__VA_ARGS__)) #endif @@ -54,6 +54,8 @@ class MallocaPtr { public: inline MallocaPtr() noexcept = default; + inline MallocaPtr(MallocaPtr &other) = delete; + inline MallocaPtr(MallocaPtr &&other) noexcept { m_size = other.m_size; m_val = other.m_val; @@ -81,6 +83,15 @@ class MallocaPtr { return reinterpret_cast(m_val); } + inline const T &operator=(MallocaPtr &other) = delete; + + inline const T &operator=(MallocaPtr &&other) noexcept { + m_size = other.m_size; + m_val = other.m_val; + other.m_size = 0; + other.m_val = nullptr; + } + inline const T *operator->() const noexcept { return reinterpret_cast(m_val); }