The following code works for a while, but then after a random period it will crash
AActor** FoundEntry = PooledAgents.FindByPredicate([newClass](AActor*& InItem)
{
// UE_LOG(LogTemp, Error, TEXT("%s %s"), *InItem->GetClass()->GetName(), *newClass->GetName());
if (InItem != nullptr)
return false;
return InItem->GetClass() == newClass;
});
I debugged the data, and in
template <typename Predicate>
ElementType* FindByPredicate(Predicate Pred)
{
for (ElementType* RESTRICT Data = GetData(), *RESTRICT DataEnd = Data + ArrayNum; Data != DataEnd; ++Data)
{
if (Pred(*Data))
{
return Data;
}
}
return nullptr;
}
*Data is null in the if check. It could be that something is marked for delete or deleted, but shouldn’t there be a check for null on the *Data before trying to use it?