From f503484daae716dd27c6969b618c443d012638b3 Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Sun, 5 Feb 2023 04:12:55 +0800 Subject: [PATCH] Update memory.h --- src/memory.h | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/src/memory.h b/src/memory.h index a28fce27..e52d801c 100644 --- a/src/memory.h +++ b/src/memory.h @@ -20,9 +20,7 @@ namespace pkpy{ shared_ptr(shared_ptr&& other) noexcept : counter(other.counter) { other.counter = nullptr; } - ~shared_ptr() { - _dec_counter(); - } + ~shared_ptr() { _dec_counter(); } bool operator==(const shared_ptr& other) const { return counter == other.counter; @@ -54,18 +52,11 @@ namespace pkpy{ return *this; } - T& operator*() const { - return *_t(); - } - T* operator->() const { - return _t(); - } - T* get() const { - return _t(); - } - int use_count() const { - return counter ? *counter : 0; - } + T& operator*() const { return *_t(); } + T* operator->() const { return _t(); } + T* get() const { return _t(); } + int use_count() const { return counter ? *counter : 0; } + void reset(){ _dec_counter(); counter = nullptr;