/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* weak_ptr.hpp :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: maldavid +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/01/20 11:17:07 by maldavid #+# #+# */ /* Updated: 2024/01/20 19:13:13 by maldavid ### ########.fr */ /* */ /* ************************************************************************** */ #ifndef __UNSTD_WEAK_PTR__ #define __UNSTD_WEAK_PTR__ #include #include namespace unstd { template class WeakPtr { public: WeakPtr(); WeakPtr(const WeakPtr& rhs); WeakPtr(const SharedPtr& shared); WeakPtr& operator=(const WeakPtr& rhs); WeakPtr& operator=(const SharedPtr& shared); void reset(); void swap(WeakPtr& rhs); bool expired() const; SharedPtr lock() const; ~WeakPtr(); private: void safeRelease(); private: bits::RefCount* _ref; T* _ptr; }; } #include #endif