Added `aligned_ptr<T>::container_address([const] Self&) -> [const] Self*` to offset the overloaded unary & and avoid need of `std::addressof`.

Fortune for cpprng's current commit: Future curse − 末凶
lib
Avril 3 years ago
parent fe55da9a5a
commit 7eaba3c1b3
Signed by: flanchan
GPG Key ID: 284488987C31F630

@ -43,6 +43,13 @@ namespace mem
template<typename T, typename H>
static inline void dealloc(T* ptr) { H::delete_object(&ptr); if(ptr) _dealloc(reinterpret_cast<void*>(ptr)); }
template<typename T>
requires (!std::is_same<T, void>::value)
inline static const aligned_ptr<T>* container_address(const aligned_ptr<T>& ptr) { return aligned_ptr<T >::container_address(ptr); }
template<typename T>
requires (!std::is_same<T, void>::value)
inline static aligned_ptr<T>* container_address( aligned_ptr<T>& ptr) { return aligned_ptr<T >::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<T>* container_address(const aligned_ptr<T>& ptr) { return ptr._this_addr(); }
inline static aligned_ptr<T>* container_address( aligned_ptr<T>& ptr) { return ptr._this_addr(); }
inline aligned_ptr<T>& operator=(aligned_ptr<T, H>&& other)
{
if(ptr) aligned_ptr_util::dealloc<T, H>(ptr);
@ -94,6 +104,9 @@ namespace mem
return *this;
}
private:
inline aligned_ptr<T>* _this_addr() { return this; }
inline const aligned_ptr<T>* _this_addr() const { return this; }
inline aligned_ptr<T>& operator=(const aligned_ptr<T, H>& other)
{
return (*this = other.clone());

Loading…
Cancel
Save