summaryrefslogtreecommitdiffhomepage
path: root/compat/safe-ptr.hpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2024-02-13 14:58:17 +0100
committerStanislaw Halik <sthalik@misaki.pl>2024-02-13 21:22:32 +0100
commit8f7b089e246b5e55d1cacb756da4219bb751236f (patch)
treeb302742a6cdc70c393c6020bc8e3b4d1bc08d348 /compat/safe-ptr.hpp
parent9b70fb78e70a509ba5bfa1c1d0a839eddd0902dc (diff)
scenery loader now works
Diffstat (limited to 'compat/safe-ptr.hpp')
-rw-r--r--compat/safe-ptr.hpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/compat/safe-ptr.hpp b/compat/safe-ptr.hpp
index 95cd3bae..68c17c76 100644
--- a/compat/safe-ptr.hpp
+++ b/compat/safe-ptr.hpp
@@ -29,6 +29,10 @@ public:
ptr(new T{ Utility::forward<Ts>(args)... })
{}
+ safe_ptr(const safe_ptr& other) noexcept:
+ ptr{new T{*other.ptr}}
+ {}
+
safe_ptr& operator=(safe_ptr&& other) noexcept
{
fm_assert(this != &other);
@@ -38,7 +42,17 @@ public:
return *this;
}
- fm_DECLARE_DELETED_COPY_ASSIGNMENT(safe_ptr);
+ safe_ptr& operator=(const safe_ptr& other) noexcept
+ {
+ if (ptr != other.ptr)
+ {
+ delete ptr;
+ ptr = nullptr;
+ if (other.ptr)
+ ptr = new T{*other.ptr};
+ }
+ return *this;
+ }
//explicit operator bool() const noexcept { return ptr != nullptr; }