[ox/std] Remove copy constructor and operator from MallocaPtr

This commit is contained in:
Gary Talent 2018-05-03 23:26:26 -05:00
parent 78a819b360
commit 1c16ef2601

View File

@ -32,7 +32,7 @@ void *operator new(std::size_t, void*) noexcept;
*/
#if defined(OX_USE_STDLIB)
#define ox_malloca(size, Type, ...) ox::MallocaPtr<Type>(size, new (size > MallocaStackLimit ? new uint8_t[size] : ox_alloca(size)) Type(__VA_ARGS__))
#else
#else
#define ox_malloca(size, Type, ...) ox::MallocaPtr<Type>(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<T*>(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<T*>(m_val);
}