diff --git a/include/mem.h b/include/mem.h index 5fcde1c..f1f9d01 100644 --- a/include/mem.h +++ b/include/mem.h @@ -43,6 +43,13 @@ namespace mem template static inline void dealloc(T* ptr) { H::delete_object(&ptr); if(ptr) _dealloc(reinterpret_cast(ptr)); } + + template + requires (!std::is_same::value) + inline static const aligned_ptr* container_address(const aligned_ptr& ptr) { return aligned_ptr::container_address(ptr); } + template + requires (!std::is_same::value) + inline static aligned_ptr* container_address( aligned_ptr& ptr) { return aligned_ptr::container_address(ptr); } private: static void* _alloc(usize align, usize size); static void _dealloc(void* ptr); @@ -85,6 +92,9 @@ namespace mem inline operator const T&() const { return get(); } inline operator T&() { return get(); } + inline static const aligned_ptr* container_address(const aligned_ptr& ptr) { return ptr._this_addr(); } + inline static aligned_ptr* container_address( aligned_ptr& ptr) { return ptr._this_addr(); } + inline aligned_ptr& operator=(aligned_ptr&& other) { if(ptr) aligned_ptr_util::dealloc(ptr); @@ -94,6 +104,9 @@ namespace mem return *this; } private: + inline aligned_ptr* _this_addr() { return this; } + inline const aligned_ptr* _this_addr() const { return this; } + inline aligned_ptr& operator=(const aligned_ptr& other) { return (*this = other.clone());