Hello. I’m trying to make a simple Container Component, that holds a TArray of items. The items are a struct - FItemInstance. There’s a function for removing items, that calls Remove on the TArray with a const & to an item (assuming the array contains it). However, using the Remove throws a whole bunch of errors, with (I think) most relevant being:
BRWContainerComponent.cpp(46): note: see reference to function template instantiation 'int TArray<FItemInstance,FDefaultAllocator>::Remove(const FItemInstance &)' being compiled
Here’s the TArray and function from .h:
UPROPERTY(VisibleAnywhere)
TArray<FItemInstance> StoredItems;
UFUNCTION(BlueprintCallable)
void RemoveItem(const FItemInstance& ItemInstance);
and here’s the function in .cpp:
void UBRWContainerComponent::RemoveItem(const FItemInstance& ItemInstance)
{
if (StoredItems.Contains(ItemInstance))
{
StoredItems.Remove(ItemInstance);
}
}
I’ve tried removing both UPROPERTY() and UFUNCTION() and it didn’t help. Any ideas what I’m doing wrong? My VS (with VA) doesn’t even highlight any errors…
I also don’t understand why only Remove() is wrong, since Contains() has the same definition and is used in the same way. EDIT: nvm it does. If I comment out Remove it breaks on Contains…