diff options
| author | Amlal El Mahrouss <amlal@nekernel.org> | 2025-07-19 11:42:49 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal@nekernel.org> | 2025-07-19 11:42:49 +0100 |
| commit | 701789c70a006d349741ce97494b867b2e22c530 (patch) | |
| tree | 96ff19ff3e98117b0934ce3ad1b912ec2cd5e04c /lib | |
| parent | 0b293838b939e0288670893db281cbe4917141c9 (diff) | |
feat: better 'tracked_ptr' module, and added 'eval_true' and 'eval_false' to 'opt.hpp'
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/logic/opt.hpp | 9 | ||||
| -rw-r--r-- | lib/memory/tracked_ptr.hpp | 17 |
2 files changed, 25 insertions, 1 deletions
diff --git a/lib/logic/opt.hpp b/lib/logic/opt.hpp index d2a9150..facbf2c 100644 --- a/lib/logic/opt.hpp +++ b/lib/logic/opt.hpp @@ -107,6 +107,15 @@ namespace snu::opt return greater_than(std::forward<Lst>(arg)...) ? return_type::okay : return_type::err; } + inline return_type eval_true() + { + return return_type::okay; + } + + inline return_type eval_false() + { + return return_type::err; + } } // namespace snu::opt #endif /* ifndef _SNU_OPT_HPP */ diff --git a/lib/memory/tracked_ptr.hpp b/lib/memory/tracked_ptr.hpp index 36b75b2..ec19151 100644 --- a/lib/memory/tracked_ptr.hpp +++ b/lib/memory/tracked_ptr.hpp @@ -107,13 +107,22 @@ namespace snu::memory ~tracked_ptr() noexcept { - tracked_ptr::manager().dispose(ptr_); + this->reset(); } tracked_ptr(const tracked_ptr&) = delete; tracked_ptr& operator=(const tracked_ptr&) = delete; public: + void reset() + { + if (ptr_) + { + tracked_ptr::manager().dispose(ptr_); + ptr_ = nullptr; + } + } + T* get() const { return ptr_; @@ -177,4 +186,10 @@ namespace snu::memory inline auto make_tracked(T&&... arg) -> tracked_ptr<U> { return tracked_ptr<U>(std::forward<T>(arg)...); } + + template <typename T> + inline void swap(tracked_ptr<T>& a, tracked_ptr<T>& b) + { + a.swap(b); + } } // namespace snu::memory
\ No newline at end of file |
