Removes completely invalid copy and move operators on unique pointers
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
This commit is contained in:
parent
74ef6b5bdc
commit
407f9aaf73
|
@ -2,6 +2,7 @@
|
||||||
#define ARBUTILS_OPTIONALOptionalUniquePtr_HPP
|
#define ARBUTILS_OPTIONALOptionalUniquePtr_HPP
|
||||||
|
|
||||||
#include "../Ensure.hpp"
|
#include "../Ensure.hpp"
|
||||||
|
#include "../Misc.hpp"
|
||||||
|
|
||||||
namespace ArbUt {
|
namespace ArbUt {
|
||||||
/// @brief An optional unique pointer is used to indicate a pointer that is owned by its holder, and will be deleted
|
/// @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) {}
|
inline OptionalUniquePtr<T>() : _raw(nullptr) {}
|
||||||
/// @brief Initialise a OptionalUniquePtr with a specific raw pointer.
|
/// @brief Initialise a OptionalUniquePtr with a specific raw pointer.
|
||||||
inline OptionalUniquePtr<T>(T* nullable ptr) : _raw(ptr){};
|
inline OptionalUniquePtr<T>(T* nullable ptr) : _raw(ptr){};
|
||||||
/// @brief Initialise a OptionalUniquePtr from a copy.
|
NO_COPY_OR_MOVE(OptionalUniquePtr<T>)
|
||||||
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()){};
|
|
||||||
|
|
||||||
~OptionalUniquePtr() noexcept { delete _raw; }
|
~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.
|
/// @brief Return whether the pointer is null or not.
|
||||||
[[nodiscard]] inline bool HasValue() const noexcept { return _raw != nullptr; }
|
[[nodiscard]] inline bool HasValue() const noexcept { return _raw != nullptr; }
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#define ARBUTILS___UNIQUEPTR_HPP
|
#define ARBUTILS___UNIQUEPTR_HPP
|
||||||
|
|
||||||
#include "../Ensure.hpp"
|
#include "../Ensure.hpp"
|
||||||
|
#include "../Misc.hpp"
|
||||||
|
|
||||||
namespace ArbUt {
|
namespace ArbUt {
|
||||||
/// @brief A unique pointer is used to indicate a pointer that is owned by its holder, and will be deleted when its
|
/// @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>() {}
|
inline UniquePtr<T>() {}
|
||||||
/// @brief Initialise a UniquePtr with a specific raw pointer.
|
/// @brief Initialise a UniquePtr with a specific raw pointer.
|
||||||
inline UniquePtr<T>(T* non_null ptr) : _raw(ptr) { EnsureNotNull(ptr); };
|
inline UniquePtr<T>(T* non_null ptr) : _raw(ptr) { EnsureNotNull(ptr); };
|
||||||
/// @brief Initialise a UniquePtr from a copy.
|
NO_COPY_OR_MOVE(UniquePtr<T>)
|
||||||
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()){};
|
|
||||||
|
|
||||||
#if !WINDOWS // This doesn't work on mingw-w64 for some reason
|
#if !WINDOWS // This doesn't work on mingw-w64 for some reason
|
||||||
UniquePtr<T>(std::nullptr_t) = delete;
|
UniquePtr<T>(std::nullptr_t) = delete;
|
||||||
|
@ -28,16 +26,6 @@ namespace ArbUt {
|
||||||
|
|
||||||
~UniquePtr() noexcept { delete _raw; }
|
~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.
|
/// @brief Assign operator with raw pointer.
|
||||||
inline UniquePtr<T>& operator=(T* non_null rhs) {
|
inline UniquePtr<T>& operator=(T* non_null rhs) {
|
||||||
if (_raw == rhs) {
|
if (_raw == rhs) {
|
||||||
|
|
Loading…
Reference in New Issue