Hello,
I am having a problem in this piece of code:
RemoveItemByOrdinality(*InventoryMap.FindKey(Slot));
In which “InventoryMap” is defined as:
TMap<int32, struct FInventorySlot> InventoryMap;
and the argument “RemoveItemByOrdinality” function takes is int32 like follows:
virtual void RemoveItemByOrdinality(int32 Ordinality);
Since the FindKey function in map returns a constant int32 pointer, it should be convertable to an int32 using a * in the front
*InventoryMap.FindKey(Slot)
however this causes errors in the compiling process that look like this:
1> C:\Users\Onat\Documents\Unreal Projects\Game\Source\Game\Inventory\Inventory.cpp(160): note: see reference to function template instantiation 'const int32 *TMapBase<KeyType,ValueType,SetAllocator,KeyFuncs>::FindKey(const FInventorySlot &) const' being compiled
1> with
1> [
1> KeyType=int32,
1> ValueType=FInventorySlot,
1> SetAllocator=FDefaultSetAllocator,
1> KeyFuncs=TDefaultMapKeyFuncs<int32,FInventorySlot,false>
1> ]
1> C:\UE4\Unreal Engine\4.12\Engine\Source\Runtime\Core\Public\Containers\Map.h(810): note: see reference to class template instantiation 'TMapBase<KeyType,ValueType,SetAllocator,KeyFuncs>' being compiled
1> with
1> [
1> KeyType=int32,
1> ValueType=FInventorySlot,
1> SetAllocator=FDefaultSetAllocator,
1> KeyFuncs=TDefaultMapKeyFuncs<int32,FInventorySlot,false>
1> ]
1> C:\UE4\Unreal Engine\4.12\Engine\Source\Runtime\Core\Public\Containers\Map.h(929): note: see reference to class template instantiation 'TSortableMapBase<KeyType,ValueType,SetAllocator,KeyFuncs>' being compiled
1> with
1> [
1> KeyType=int32,
1> ValueType=FInventorySlot,
1> SetAllocator=FDefaultSetAllocator,
1> KeyFuncs=TDefaultMapKeyFuncs<int32,FInventorySlot,false>
1> ]
1> c:\users\onat\documents\unreal projects\game\source\game\character\../Inventory/Inventory.h(33): note: see reference to class template instantiation 'TMap<int32,FInventorySlot,FDefaultSetAllocator,TDefaultMapKeyFuncs<KeyType,ValueType,false>>' being compiled
1> with
1> [
1> KeyType=int32,
1> ValueType=FInventorySlot
1> ]
Could anyone tell me what I’m doing wrong?
Any help will be appreciated,
Thanks!