I have a similar data structure:
struct Data { std::string id; Blob data; };
Now I can use std::map to store the structure and search by identifier, but I'm looking for a way to achieve the same with std::set (since I really don't need to separate the identifier and structure).
std::set::find , of course, takes the type key 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. This will require a constructor that allows an ID without data, plus I donβt really like to construct an object, just to use it as a search key.
So my question is: is there a better way?
source share