3 ms·
The main problem with more precise strategies is that they only work in precise situations. New/delete and RAII and malloc/free (be it either unique_ptr source
by dragontamer 5y ago
The main problem with more precise strategies is that they only work in precise situations.
New/delete and RAII and malloc/free (be it either unique_ptr source/sink pattern or RAII pattern) are basically universal techniques, albeit at a performance cost.
There are many other strategies but they require more thought.
-------
Personally, I'm a big fan of vector + swap with the end, which covers most of my common needs.
When looking at linked structures: linked list, trees, and graphs... It's often common that your specific application has patterns that a more specific strategy (arena allocation, stack allocation/bump allocation) works out.
But there is also the chance it doesn't work out, and prototyping with generic methods (new/delete/RAII or garbage collection) is a good first step.