In my game engine, there is a pointer stored in the entity manager class to the currently selected entity. In the entity manager, there is also a vector of unique pointers to all the entities in the scene. I want to set up a duplication feature, where the selected entity is pushed back into the vector with the id modified, but otherwise the same.
I tried:
if (selectedEntity) {
    Entity e = *selectedEntity;
    e.id = currentID;
    currentID++;
    std::unique_ptr<Entity> uPtr{ &e }; 
    entities.emplace_back(std::move(uPtr));
}
But it causes errors that say I'm trying to reference a deleted function. My guess is it's to do with the line std::unique_ptr<Entity> uPtr{ &e };, but I'm not sure how to fix it. How can I handle this in a way that is efficient, and that will work every time?
 
    