But it doesn’t works, il only returns 1 and there are at least 2
objects in my map that have same id
It’s a std::map
. You cannot have two objects with the same key, and I assume you’re trying to use the m_id
filed of O
as your key. Try using std::multimap
instead.
And, to count the number of items, use map::count()
(which for std::map can only return one or zero!)
7
solved Count occurrences by object id in std::multimap [closed]