I use Codeblocks, this function to add a ShapePtr to a vector of ShapePtr doesn't add anything to the vector.
typedef Shape* ShapePtr;
void insertGrouped(vector<ShapePtr> arr, const ShapePtr &Sh)
{
int flag = 0;
if(arr.empty())
{
arr.push_back(Sh);
}
for(int i = 0; i < arr.size(); i++)
{
if(arr[i]->getType() == Sh->getType())
{
arr.insert(arr.begin() + i, Sh);
flag = 1;
break;
}
}
if(flag == 0)
arr.push_back(Sh);
}