I've been working on some game engine for some weeks using raw pointer and references and i decided to migrate to smart pointer before the project gets too advanced. To be honest i was fine with raw pointer but i came across a library i definitely want to use (Cereal) and somehow it won't be possible if i don't update myself and start using those smart pointer...
Anyway i am somewhat confused how smart pointer can totally replace references in my software.
Basicly i have a Scene class that contain gameentities. I have references in my game entity that point to the scene wich they belong so i can access public method of my scene from any entity in that scene.
I think this is a fairly normal thing to do and so far i was very satisfied with that. However i don't get how smart pointer can take over the references here. Basicly from what i've seen i can't use smart pointer to point to any variable on the stack without risking corrupting my memory and the scenes happens to be declared on the stack (in a vector inside the gamestate class)
So what i am supposed to do? Is everything supposed to be declared on the heap now that i want to use smart pointer? How about that vector of scene ? Is everything that i want to ever reference elsewhere now is supposed to be constructed from a smart pointer because somehow is it now impossible to point to something that wasn't a smart pointer in the first place so every container now have to be container of smart pointer instead of just being vector of object?
Any tips would be greatly appreciated.