Well to fully use count you need to do operator overloading. Open up a blank C++ project and make a custom class with several different sub classes. You'll have the same issues if you don't tell C++ how to compare your classes & objects. Since it doesn't know how to do that for you by default. It knows how to compare datatypes like numbers already so that is why it works.
We also need to know what kind of check are you wanting to do. Type Only, Static Stats Only, Changing Stats Only, Location, Action, etc. Judging from what you are saying I'd say Type Comparison is what you are looking for.
Was trying to come up with an example but even I need to work on my C++ more. In this case it can get count partly working but it still needs changes for it to work with subclasses. Think of it as a challenge to figure it out.
in .h file
bool operator ==(const TypeCheckedOBJ &)const;
bool operator !=(const TypeCheckedOBJ &rightside)const
{
return !(*this == rightside);
}
in .cpp file
bool TypeCheckedOBJ::operator ==(const TypeCheckedOBJ &rightside)const
{
return (typeid(*this) == typeid(rightside));
}
in main
TypeCheckedOBJ test1("Test1"), test2("Test2");
TypeCheckedOne test3("Test3"), test4("Test4");
TypeCheckedTwo test5("Test5"), test6("Test6");
vector<TypeCheckedOBJ> objlist;
objlist.push_back(test1);
objlist.push_back(test2);
objlist.push_back(test3);
objlist.push_back(test4);
objlist.push_back(test5);
objlist.push_back(test6);
cout << "Count Test_1: " << count(objlist.begin(), objlist.end(), test1) << endl;
cout << "Count Test_2: " << count(objlist.begin(), objlist.end(), test3) << endl;
cout << "Count Test_3: " << count(objlist.begin(), objlist.end(), test5) << endl;
I made a base class and two sub classes off of it to test. In this case count likely fails for the sub classes because everyone is because changed to the base class. From here though it should be easy to find a solution. Since this is a pure C++ issue hunt around some site that help C++ programmers.
Keep in mind this code above is what can be used with any class if you change out the class names. Meantime I'll keep working on this for when it might be useful again.
Keep in mind though there are many other ways but since you wanted to use count I wanted to see if count was even usable. It is just there might be more work than it is worth to get it to fully work.