I have an array of self-written class A
. I'm sorry for my tactlessness, but I'm confused about the modules. How do I correctly find a specific object fragment
inside the array and delete it? I don't quite understand which modules to use to do this optimally.
A[] arr;
A fragment = new A;
...
arr.remove(fragment); // Something like
In the pros, I would do it this way, for example via lambda
arr.erase(std::find_if(arr.cbegin(), arr.cend(), [&](const std::reference_wrapper<A> &item)
{
return &item.get() == &fragment;
}));