So I want to do some error checking on a vector that I have in a class to see if the item already exists before adding the new item to the vector.
ClassA cpp
void ClassA::func(std::shared_ptr<ClassB> new_item)
{
for(auto items : vector_)
{
if(items = new_item)
{
return;
}
vector_.push_back(new_item);
}
}
vector_ is the member class member std::vector. With this current implementation all new_item are being ignored even if it is not a duplicate. I know that 'if(items = new_item)' is the problematic line but I do not know why.