Removes completely invalid copy and move operators on unique pointers
continuous-integration/drone/push Build is failing Details

This commit is contained in:
Deukhoofd 2022-05-14 15:58:23 +02:00
parent 74ef6b5bdc
commit 407f9aaf73
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
2 changed files with 4 additions and 26 deletions

View File

@ -2,6 +2,7 @@
#define ARBUTILS_OPTIONALOptionalUniquePtr_HPP
#include "../Ensure.hpp"
#include "../Misc.hpp"
namespace ArbUt {
/// @brief An optional unique pointer is used to indicate a pointer that is owned by its holder, and will be deleted
@ -17,21 +18,10 @@ namespace ArbUt {
inline OptionalUniquePtr<T>() : _raw(nullptr) {}
/// @brief Initialise a OptionalUniquePtr with a specific raw pointer.
inline OptionalUniquePtr<T>(T* nullable ptr) : _raw(ptr){};
/// @brief Initialise a OptionalUniquePtr from a copy.
inline OptionalUniquePtr<T>(const OptionalUniquePtr<T>& other) : _raw(other._raw){};
/// @brief Initialise a OptionalUniquePtr with a std unique_ptr.
inline OptionalUniquePtr<T>(const std::unique_ptr<T>& other) : _raw(other.get()){};
NO_COPY_OR_MOVE(OptionalUniquePtr<T>)
~OptionalUniquePtr() noexcept { delete _raw; }
/// @brief Copy operator.
inline OptionalUniquePtr<T>& operator=(const OptionalUniquePtr<T>& rhs) {
if (this == &rhs) {
return *this;
}
_raw = rhs._raw;
return *this;
}
/// @brief Return whether the pointer is null or not.
[[nodiscard]] inline bool HasValue() const noexcept { return _raw != nullptr; }

View File

@ -2,6 +2,7 @@
#define ARBUTILS___UNIQUEPTR_HPP
#include "../Ensure.hpp"
#include "../Misc.hpp"
namespace ArbUt {
/// @brief A unique pointer is used to indicate a pointer that is owned by its holder, and will be deleted when its
@ -17,10 +18,7 @@ namespace ArbUt {
inline UniquePtr<T>() {}
/// @brief Initialise a UniquePtr with a specific raw pointer.
inline UniquePtr<T>(T* non_null ptr) : _raw(ptr) { EnsureNotNull(ptr); };
/// @brief Initialise a UniquePtr from a copy.
inline UniquePtr<T>(const UniquePtr<T>& other) : _raw(other._raw){};
/// @brief Initialise a UniquePtr with a std unique_ptr.
inline UniquePtr<T>(const std::unique_ptr<T>& other) : _raw(other.get()){};
NO_COPY_OR_MOVE(UniquePtr<T>)
#if !WINDOWS // This doesn't work on mingw-w64 for some reason
UniquePtr<T>(std::nullptr_t) = delete;
@ -28,16 +26,6 @@ namespace ArbUt {
~UniquePtr() noexcept { delete _raw; }
/// @brief Copy operator.
inline UniquePtr<T>& operator=(const UniquePtr<T>& rhs) {
if (this == &rhs) {
return *this;
}
delete _raw;
_raw = rhs._raw;
return *this;
}
/// @brief Assign operator with raw pointer.
inline UniquePtr<T>& operator=(T* non_null rhs) {
if (_raw == rhs) {