I’m wondering if there a way to intersect or make the differences between two structures defined as std::set<MyData*> and std::map<MyData*, MyValue> with standard algorithms (like std::set_intersect)
The problem is that I need to compute the difference between the set and the keyset of the map but I would like to avoid reallocating it (since it’s something that is done many times per second with large data structures). Is there a way to obtain a “key view” of the std::map? After all what I’m looking is to consider just the keys when doing the set operation so from an implementation point it should be possible but I haven’t been able to find anything.
You can use
transform_iteratorfrom boost in order to adapt thestd::mapiterator and to return only the keys: