>>101563599
It seems you are trying to implement unique_ptr, i'll give you some tips:
Always theck if this->m_ptr is not null before calling delete
For your assignment operators, you can use friend to explicitly qualify what kind of operations are allowed i.e
// Moves self into other
friend Auto_ptr5& operator=(Auto_ptr5& self, Auto_ptr5&& other)
{
if (self.m_ptr) delete self.m_ptr;
self.m_ptr = other.m_ptr;
other.m_ptr = nullptr
return self;
}
You can also use the deducing this feature, but I don't think it's very stable right now
Also you should provide a way to automatically create your auto_ptr i.e
template <class U, class... Ts>
decltype(auto) make_autoptr5(Ts&&... ts)
{
return Auto_ptr5(new U(std::forward<Ts>(ts)...));
}
If i were you, i'd disable the possibility to create an Auto_ptr from a raw pointer or throw an exception if it is null because your dereference method might crash your program when least expect it