Template Class PtrWrapper

Class Documentation

template<typename T>
class PtrWrapper

A wrapper around a pointer which will automatically deallocate the resource when it goes out of scope.

Intended for use in situations where shared_ptr can’t be used, such as when the resource is not allocated with new

Public Functions

PtrWrapper() = default
inline PtrWrapper(T *ptr, std::function<void(T*)> deallocator)
inline PtrWrapper(std::function<T*(void)> allocator, std::function<void(T*)> deallocator)
inline ~PtrWrapper()
PtrWrapper(const PtrWrapper&) = delete
inline PtrWrapper(PtrWrapper &&other) noexcept
PtrWrapper &operator=(PtrWrapper) = delete
inline PtrWrapper &operator=(PtrWrapper &&other) noexcept
inline PtrWrapper &operator=(T *ptr)
inline T **operator&()
inline virtual explicit operator T*() const
inline virtual T *operator*() const
inline virtual T *operator->() const
inline virtual T *get() const

Friends

inline friend void swap(PtrWrapper &first, PtrWrapper &second)