Indigo icon indicating copy to clipboard operation
Indigo copied to clipboard

core: replace `Obj` with standard smart pointer

Open mkviatkovskii opened this issue 3 years ago • 0 comments

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

  1. Find all places in code that use Obj<T>.
  2. Check if they could be replaced with T (no null state, no replacing object in container, T has default constructor etc) and replace it with T if possible.
  3. If not possible, try to replace it with std::unique_ptr<T>.
  4. In some cases this class returns a raw pointer to contained instance of T. Check if it makes sense to use a std::shared_ptr<T> instead to make it more convenient and safe.

mkviatkovskii avatar Nov 11 '21 20:11 mkviatkovskii