I have a similar data structure like this:
struct Data { std::string id; Blob data; };
Now I can use a std::map
to store the structure and search by ID, but I searching for a way to achieve the same thing with a std::set
(since I don't really need to separate the ID and the structure).
std::set::find
of course takes the key type as a parameter, so I could do something like this (with the appropriate constructor):
set<Data> x; x.find(Data("some_id"));
But I would like to avoid this if possible. It would require having a constructor that allows ID without data, plus I don't really like constructing an object, just to use it as a key for search.
So my question is: Is there a better way?