From 574d373163f7edade42e935b9e6957cdaf08d94b Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Wed, 30 Jul 2025 09:07:51 +0100 Subject: feat: 'dispose' now takes T* as a reference. Signed-off-by: Amlal El Mahrouss --- dev/lib/logic/math.hpp | 2 +- dev/lib/memory/tracked_ptr.hpp | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) (limited to 'dev/lib') diff --git a/dev/lib/logic/math.hpp b/dev/lib/logic/math.hpp index 2613799..3ea99dc 100644 --- a/dev/lib/logic/math.hpp +++ b/dev/lib/logic/math.hpp @@ -11,7 +11,7 @@ namespace snu::math { - template + template struct is_non_boolean_integer final { static constexpr const bool value = true; diff --git a/dev/lib/memory/tracked_ptr.hpp b/dev/lib/memory/tracked_ptr.hpp index 238d521..b7e55f7 100644 --- a/dev/lib/memory/tracked_ptr.hpp +++ b/dev/lib/memory/tracked_ptr.hpp @@ -46,7 +46,7 @@ namespace snu::memory } } - void dispose(T* ptr) + void dispose(T*& ptr) { if (ptr) { @@ -68,7 +68,7 @@ namespace snu::memory tracked_allocator allocator_; public: - const tracked_allocator& allocator() + const tracked_allocator& allocator() noexcept { return allocator_; } @@ -81,7 +81,7 @@ namespace snu::memory return ptr; } - void dispose(T* ptr) + void dispose(T*& ptr) { allocator_.dispose(ptr); } @@ -91,7 +91,7 @@ namespace snu::memory class tracked_ptr { public: - static Mgr& manager() + static Mgr& manager() noexcept { static Mgr mgr; return mgr; @@ -99,7 +99,7 @@ namespace snu::memory public: template - explicit tracked_ptr(U&&... args) + tracked_ptr(U&&... args) : ptr_(nullptr) { ptr_ = tracked_ptr::manager().retain(std::forward(args)...); @@ -119,7 +119,6 @@ namespace snu::memory if (ptr_) { tracked_ptr::manager().dispose(ptr_); - ptr_ = nullptr; } } -- cgit v1.2.3