summaryrefslogtreecommitdiffhomepage
path: root/dev
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@nekernel.org>2025-07-30 09:07:51 +0100
committerAmlal El Mahrouss <amlal@nekernel.org>2025-07-30 09:07:51 +0100
commit574d373163f7edade42e935b9e6957cdaf08d94b (patch)
treea8a94407f9875a700ffd7456b9f00c9341e713e1 /dev
parentc52dbf5513ae7f106634967162da5cfb01dc5af3 (diff)
feat: 'dispose' now takes T* as a reference.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'dev')
-rw-r--r--dev/lib/logic/math.hpp2
-rw-r--r--dev/lib/memory/tracked_ptr.hpp11
2 files changed, 6 insertions, 7 deletions
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 <size_t T>
+ template <std::size_t T>
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<T> allocator_;
public:
- const tracked_allocator<T>& allocator()
+ const tracked_allocator<T>& 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 <typename... U>
- explicit tracked_ptr(U&&... args)
+ tracked_ptr(U&&... args)
: ptr_(nullptr)
{
ptr_ = tracked_ptr::manager().retain(std::forward<U>(args)...);
@@ -119,7 +119,6 @@ namespace snu::memory
if (ptr_)
{
tracked_ptr::manager().dispose(ptr_);
- ptr_ = nullptr;
}
}