From 9f17fc58d6af9a64c2ca8ca2d55ea66d16f7e79c Mon Sep 17 00:00:00 2001 From: Namonay Date: Tue, 6 Feb 2024 11:54:39 +0100 Subject: [PATCH] removed unnecesary includes --- includes/unstd/unique_ptr.hpp | 55 ----------------- includes/unstd/unique_ptr.ipp | 103 -------------------------------- includes/unstd/weak_ptr.hpp | 51 ---------------- includes/unstd/weak_ptr.ipp | 109 ---------------------------------- 4 files changed, 318 deletions(-) delete mode 100644 includes/unstd/unique_ptr.hpp delete mode 100644 includes/unstd/unique_ptr.ipp delete mode 100644 includes/unstd/weak_ptr.hpp delete mode 100644 includes/unstd/weak_ptr.ipp diff --git a/includes/unstd/unique_ptr.hpp b/includes/unstd/unique_ptr.hpp deleted file mode 100644 index 69e044b..0000000 --- a/includes/unstd/unique_ptr.hpp +++ /dev/null @@ -1,55 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* unique_ptr.hpp :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: maldavid +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/01/20 09:40:56 by maldavid #+# #+# */ -/* Updated: 2024/01/20 19:12:51 by maldavid ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#ifndef __UNSTD_UNIQUE_PTR__ -#define __UNSTD_UNIQUE_PTR__ - -#include - -namespace unstd -{ - template - class UniquePtr - { - public: - UniquePtr(); - UniquePtr(UniquePtr& ptr); - explicit UniquePtr(T* ptr); - - inline T* get(); - - inline void swap(const UniquePtr& ptr); - - inline void reset(T* ptr = NULL); - inline T* release(); - - inline operator bool() const; - - inline UniquePtr& operator=(T* ptr); - - inline T* operator->() const; - inline T& operator*() const; - - ~UniquePtr(); - - private: - UniquePtr(const UniquePtr& ptr); - inline UniquePtr& operator=(const UniquePtr& ptr); - - private: - T* _ptr; - }; -} - -#include - -#endif diff --git a/includes/unstd/unique_ptr.ipp b/includes/unstd/unique_ptr.ipp deleted file mode 100644 index 95b948c..0000000 --- a/includes/unstd/unique_ptr.ipp +++ /dev/null @@ -1,103 +0,0 @@ -/* **************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* unique_ptr.tpp :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: maldavid +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/01/20 09:53:45 by maldavid #+# #+# */ -/* Updated: 2024/01/20 09:53:45 by maldavid ### ########.fr */ -/* */ -/* **************************************************************************** */ - -#include - -namespace unstd -{ - template - UniquePtr::UniquePtr() : _ptr(NULL) {} - - template - UniquePtr::UniquePtr(T* ptr) : _ptr(ptr) {} - - template - UniquePtr::UniquePtr(UniquePtr& rhs) : _ptr(rhs._ptr) - { - rhs._ptr = NULL; - } - - template - T* UniquePtr::get() - { - return _ptr; - } - - template - void UniquePtr::swap(const UniquePtr& ptr) - { - T* temp = _ptr; - _ptr = ptr._ptr; - ptr._ptr = temp; - } - - template - void UniquePtr::reset(T* ptr) - { - if(_ptr != NULL) - delete _ptr; - _ptr = ptr; - } - - template - T* UniquePtr::release() - { - T* temp = _ptr; - _ptr = NULL; - return temp; - } - - template - UniquePtr::operator bool() const - { - return _ptr != NULL; - } - - template - UniquePtr& UniquePtr::operator=(T* ptr) - { - assert(_ptr == NULL && "UniquePtr assertion failed : `operator=`, unique ptr already holds a pointer"); - reset(ptr); - } - - template - T* UniquePtr::operator->() const - { - return _ptr; - } - - template - T& UniquePtr::operator*() const - { - return *_ptr; - } - - template - UniquePtr::~UniquePtr() - { - if(_ptr != NULL) - delete _ptr; - } - - template - UniquePtr::UniquePtr(const UniquePtr& ptr) - { - (void)ptr; - } - - template - UniquePtr& UniquePtr::operator=(const UniquePtr& ptr) - { - (void)ptr; - return *this; - } -} diff --git a/includes/unstd/weak_ptr.hpp b/includes/unstd/weak_ptr.hpp deleted file mode 100644 index 6e5e9b2..0000000 --- a/includes/unstd/weak_ptr.hpp +++ /dev/null @@ -1,51 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* 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 diff --git a/includes/unstd/weak_ptr.ipp b/includes/unstd/weak_ptr.ipp deleted file mode 100644 index 0cb05b6..0000000 --- a/includes/unstd/weak_ptr.ipp +++ /dev/null @@ -1,109 +0,0 @@ -/* **************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* weak_ptr.ipp :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: maldavid +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/01/20 12:58:44 by maldavid #+# #+# */ -/* Updated: 2024/01/20 12:58:44 by maldavid ### ########.fr */ -/* */ -/* **************************************************************************** */ - -namespace unstd -{ - template - WeakPtr::WeakPtr() : _ref(NULL), _ptr(NULL) {} - - template - WeakPtr::WeakPtr(const WeakPtr& rhs) : _ref(rhs._ref), _ptr(rhs._ptr) - { - if(_ptr && _ref) - _ref->weak++; - } - - template - WeakPtr::WeakPtr(const SharedPtr& shared) : _ref(shared._ref), _ptr(shared._ptr) - { - if(_ptr && _ref) - _ref->weak++; - } - - template - WeakPtr& WeakPtr::operator=(const WeakPtr& rhs) - { - if(_ptr == rhs._ptr) - return *this; - - safeRelease(); - _ptr = rhs._ptr; - _ref = rhs._ref; - return *this; - } - - template - WeakPtr& WeakPtr::operator=(const SharedPtr& shared) - { - if(_ptr == shared._ptr) - return *this; - - safeRelease(); - _ptr = shared._ptr; - _ref = shared._ref; - _ref->weak++; - return *this; - } - - template - void WeakPtr::reset() - { - safeRelease(); - _ptr = NULL; - _ref = NULL; - } - - template - void WeakPtr::swap(WeakPtr& rhs) - { - T* tmptr = _ptr; - bits::RefCount* tmpref = _ref; - _ptr = rhs._ptr; - _ref = rhs._ref; - rhs._ptr = tmptr; - rhs._ref = tmpref; - } - - template - bool WeakPtr::expired() const - { - return (_ptr && _ref && _ref->shared > 0); - } - - template - SharedPtr WeakPtr::lock() const - { - return (expired() ? SharedPtr() : SharedPtr(_ptr)); - } - - template - void WeakPtr::safeRelease() - { - if(_ref == NULL) - return; - _ref->weak--; - if(_ref && _ref->shared <= 0) - { - delete _ptr; - _ptr = NULL; - delete _ref; - _ref = NULL; - } - } - - template - WeakPtr::~WeakPtr() - { - if(_ptr && _ref && _ref->shared > 0) - safeRelease(); - } -}