Having two maps which entries values are shared_ptr
, I want to compare them using operator==
.
std::map<std::string, std::shared_ptr<MyClass>> map1
std::map<std::string, std::shared_ptr<MyClass>> map2
map1 == map2
will compare keys and also values. But when the values are compared, as std::shared_ptr::operator==
compares std::shared_ptr::get()
, Im comparing pointers and not values (I would like to use MyClass::operator==
)
What is the best solution for this case?
Im not sure if the solution could be to create a custom std::shared_ptr<MyClass>::operator==
function, or create a custom std::map::value_comp
to compare the shared_ptr
objects properly.
Aucun commentaire:
Enregistrer un commentaire