A vector of unique_ptrs pointing to unique_ptrs

Sorry for such a basic question, I'm coming back to C++ after like 15 years and having a really hard time finding sources that explain how vectors interact with smart pointers.

I have a class called "Map". Inside it are two vectors.

1
2
3
4
std::vector<Room> Rooms;
std::vector<Room*> ActiveRooms; // each entry points back to a room in Rooms

n = ActiveRooms[i]->X; // this works 


However, I have now changed these vectors to use unique_ptr instead:

1
2
3
4
std::vector<std::unique_ptr<Room>> Rooms;
std::vector<std::unique_ptr<Room*>> ActiveRooms;

n = ActiveRooms[i]->X // this does NOT work! 


What is the syntax to get elements from the room in Rooms that ActiveRooms is pointing to? Did I set this up incorrectly? I'm going nuts here.
The correct syntax would be (*ActiveRooms[i])->X, however, I have to ask why you would ever want to dynamically allocate a bunch of single naked pointers. Allocating dynamically single basic type instances is extremely unusual.
Couldn't you get the same functionality by retyping ActiveRooms to std::vector<Room *>?
About using std::vector<Room*>, I was under the impression that I would have to use new and delete with each entry which is now discouraged, but since you asked I realized that is not the case with pointers.

Well! I guess I learned two things. Thank you very much.
Topic archived. No new replies allowed.