36 return alignedNew<T>(*ptr);
44 return makeAuto<TypedCloner<T>>(*this);
62 , cloner(
std::move(cloner)) {}
69 template <typename T2, typename = std::enable_if_t<std::is_convertible<T2*, T*>::value>>
77 template <typename T2, typename = std::enable_if_t<std::is_convertible<T2*, T*>::value>>
81 template <typename T2, typename = std::enable_if_t<std::is_convertible<T2*, T*>::value>>
83 : ptr(
std::move(other.ptr))
84 , cloner(
std::move(other.cloner)) {}
90 template <typename T2, typename = std::enable_if_t<std::is_convertible<T2*, T*>::value>>
95 template <typename T2, typename = std::enable_if_t<std::is_convertible<T2*, T*>::value>>
97 ptr = std::move(other.ptr);
98 cloner = std::move(other.cloner);
102 template <typename T2, typename = std::enable_if_t<std::is_convertible<T*, T2*>::value>>
105 return std::move(ptr);
108 template <typename T2, typename = std::enable_if_t<std::is_convertible<T*, T2*>::value>>
110 return this->
clone();
137 explicit operator bool()
const {
146 template <
typename T>
151 template <
typename T>
156 template <
typename T>
161 template <
typename T>
166 template <
typename T,
typename... TArgs>
168 return ClonePtr<T>(alignedNew<T>(std::forward<TArgs>(args)...));
#define SPH_ASSERT(x,...)
Simplified implementation of std::unique_ptr, using only default deleter.
INLINE AutoPtr< T > makeAuto(TArgs &&... args)
INLINE ClonePtr< T > makeClone(TArgs &&... args)
INLINE bool operator==(const ClonePtr< T > &ptr, const std::nullptr_t &)
INLINE bool operator!=(const ClonePtr< T > &ptr, const std::nullptr_t &)
#define INLINE
Macros for conditional compilation based on selected compiler.
#define NAMESPACE_SPH_END
Wrapper of pointer that deletes the resource from destructor.
INLINE RawPtr< T > get() const
ClonePtr< T > clone() const
Explicitly create a new copy.
ClonePtr & operator=(ClonePtr< T2 > &&other)
ClonePtr & operator=(const ClonePtr< T2 > &other)
ClonePtr(const ClonePtr &other)
ClonePtr & operator=(const ClonePtr &other)
ClonePtr(ClonePtr< T2 > &&other)
RawPtr< T > operator->() const
ClonePtr(const ClonePtr< T2 > &other)
virtual void * clonePtr() const override
virtual AutoPtr< Cloner > cloneThis() const override
Non-owning wrapper of pointer.
Overload of std::swap for Sph::Array.
virtual void * clonePtr() const =0
virtual AutoPtr< Cloner > cloneThis() const =0
Base class for all polymorphic objects.