Timeline for How to store a vector of smart pointers, except some of them are owned by another object?
Current License: CC BY-SA 4.0
7 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Sep 7, 2020 at 1:09 | comment | added | davidbak | Also w.r.t. overhead, if you create the pointer with make_shared the heap/memory overhead is reduced too - both space and time. | |
| Sep 6, 2020 at 17:24 | history | edited | amon | CC BY-SA 4.0 | space overhead is a thing, but less of a concern here |
| Sep 6, 2020 at 17:23 | comment | added | amon | @BakedPotato well, there's a bit of memory overhead from shared ptrs that I didn't go into. But that shouldn't matter in most cases. The important part is that you only store the game objects as shared ptrs, but your other code can use shared_ptr::get() and use them as raw pointers as before. | |
| Sep 6, 2020 at 17:05 | comment | added | Deduplicator | Nice overview of different strategies and tradeoffs. | |
| Sep 6, 2020 at 16:30 | comment | added | Luke B | Thanks for this answer! That's a good point that level creation and destruction is rare, so the overhead will be very small. And shared pointers are probably already optimized a ton so it will barely matter. | |
| Sep 6, 2020 at 16:27 | vote | accept | Luke B | ||
| Sep 6, 2020 at 7:32 | history | answered | amon | CC BY-SA 4.0 |