I have a set of unique pointers pointing to objects. Sometimes I find some of the source pointers to these objects, so other parts of the code can do things with objects. This code does not know if pointers point to objects supported by a specific set of unique pointers or not, so I need to check if the object that the pointer points to is in a unique set of pointers.
In simple code:
int* x = new int(42); std::set<std::unique_ptr<int>> numbers; numbers.insert(std::unique_ptr<int>(x)); numbers.find(x)
I understand why the code does not compile, but I cannot think of a way to search for an element with STL. Is there anything that satisfies my needs, or will I have to iterate over all the elements of the set manually?
Chris source share