I'm looking for a data structure to store instances of a specific class in, that should then be easily accessible through a public string attribute of the class. I could just use a list or a vector and search for an Item with the identifier but I think there's a smarter solution, maybe even a data structure from the std that fits the problem.
It doesn't need to be ultra fast and there won't be many elements (maybe up to 30).
This is just concept code but feel free to comment.
Update:
I think it could also be possible if the identifiers weren't members of the Item class: void addItem(Item& item, const std::string& identifier)
If you want to use a map to access any object, you might consider a class with void* and some sort of type identifying enum. Though this would require knowing at runtime the type of objects you were putting in the map and would be frowned on by some!