Indigo
Indigo copied to clipboard
core: replace `Obj` with standard smart pointer
Motivation
Currently Indigo uses a strange template class Obj<T>
defined in core/indigo-core/common/base_cpp/obj.h
. It allocates memory for T
and can create an instance of T
there, give access to it using ->
operator and clear memory.
So it looks much like std::unique_ptr
, at least at the first sight. And it contains several template create
methods instead of variadic template make_unique
.
ToDo
- Find all places in code that use
Obj<T>
. - Check if they could be replaced with
T
(no null state, no replacing object in container,T
has default constructor etc) and replace it withT
if possible. - If not possible, try to replace it with
std::unique_ptr<T>
. - In some cases this class returns a raw pointer to contained instance of
T
. Check if it makes sense to use astd::shared_ptr<T>
instead to make it more convenient and safe.