This style is also more cache friendly if you are going to be looping through the elements.
This style is also more cache friendly if you are going to be looping through the elements.
I only really use C++ for a toy game engine right now and in that codebase I don’t use any smart pointers and most objects/functions get passed references to their object dependencies. I classify objects into groups where each groups ownership is very clear. So its owner is responsible for maintaining the memory and any raw pointers can always be assumed to be borrowed references. I use handles then the underlying objects lifetime might differ from whatever is holding a handle to it. Short lived objects are kept trivial and allocated from stack/bump allocators or pools and reset at well defined times (every frame, end of level, etc)
I’m much happier this way than when I used smart pointers or when I had less well defined memory ownership.
(Not really a c++ expert, but that's my understanding; someone more knowledgeable can correct me).
I have not been working (yet) on custom allocators, but that's on the roadmap: https://pagghiu.github.io/SaneCppLibraries/library_container...