I wonder if it is possible to hold dynamically with std::unique_ptr or new(...) created objects in an array in C++ without the need to do manual memory management. Like with juce::OwnedArray.
It’s a question that comes to my mind from time to time and I wasn’t able to find a solution so far. My goal is to use as many standard C++ features from the std namespace as possible, especially in the DSP-related code.
Or is it common to avoid this situation and only use objects with a default constructor that I can put into arrays on the stack and add some init functions that take the dependent objects?
Thanks for the fast answer and for the hint about the JUCE codebase. I’m surprised that it is so simple and that this is already memory leak safe. I will use that one from now on.
In a lot of cases, I do not manipulate the list itself while the program is running. I only need access to the entries with an index. Because of this, I don’t need most of the OwnedArray features.
I prefer standard language features if possible because of portability and also for educational reasons.