adding and removing structs from a data structure

I'm trying to find a data structure to which structs can be added or removed based on user input of the struct name. I thought I had found something promising in vectors since vectorname.pushback(structname) will add the struct to the end of the vector by name.

However, I can't find a way to remove the struct by name. pop_back() removes the last element based on position and clear()just removes everything. Is there a way to remove an element from the middle of a vector or a better data structure to use in this scenario?
> Is there a way to remove an element from the middle of a vector

Locate the element and then use erase()
https://en.cppreference.com/w/cpp/container/vector/erase


> a better data structure to use in this scenario?

Consider using a map, with the name as the key.
https://en.cppreference.com/w/cpp/container/map
Topic archived. No new replies allowed.