mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 03:20:18 +00:00
Update memory.h
This commit is contained in:
parent
48e91c4f50
commit
f503484daa
21
src/memory.h
21
src/memory.h
@ -20,9 +20,7 @@ namespace pkpy{
|
|||||||
shared_ptr(shared_ptr&& other) noexcept : counter(other.counter) {
|
shared_ptr(shared_ptr&& other) noexcept : counter(other.counter) {
|
||||||
other.counter = nullptr;
|
other.counter = nullptr;
|
||||||
}
|
}
|
||||||
~shared_ptr() {
|
~shared_ptr() { _dec_counter(); }
|
||||||
_dec_counter();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator==(const shared_ptr& other) const {
|
bool operator==(const shared_ptr& other) const {
|
||||||
return counter == other.counter;
|
return counter == other.counter;
|
||||||
@ -54,18 +52,11 @@ namespace pkpy{
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
T& operator*() const {
|
T& operator*() const { return *_t(); }
|
||||||
return *_t();
|
T* operator->() const { return _t(); }
|
||||||
}
|
T* get() const { return _t(); }
|
||||||
T* operator->() const {
|
int use_count() const { return counter ? *counter : 0; }
|
||||||
return _t();
|
|
||||||
}
|
|
||||||
T* get() const {
|
|
||||||
return _t();
|
|
||||||
}
|
|
||||||
int use_count() const {
|
|
||||||
return counter ? *counter : 0;
|
|
||||||
}
|
|
||||||
void reset(){
|
void reset(){
|
||||||
_dec_counter();
|
_dec_counter();
|
||||||
counter = nullptr;
|
counter = nullptr;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user