HeapPop() Compile Error when use TArray of pointers

I have a class ATRPGTile which extends AActor. I’m creating a simple A* algorithm which uses a TArray<ATRPGTile*> as a heap. As soon as I use HeapPop() I get the following build error:

C:\Program Files\Epic Games\UE_5.0\Engine\Source\Runtime\Core\Public\Templates\Sorting.h(38): error C2664: ‘bool TLess<ATRPGTile *>::operator ()(const T &,const T &) const’: cannot convert argument 1 from ‘T’ to ‘const T &’

In my ATRPGTile class, I’ve overloaded the < operator with the following code:


In case it is relevant, this is how I’m using the TArray in my A* function:


I don’t really understand the error or how to fix it. I’ve never done an operator overload before so I’m not sure if that is the issue, or if there is an issue with how I’m using TArray.


I managed to get my code to compile. The only way I was able to get it to work was to create a predicate function in the header file for the class I’m using as a pointer in my TArray, ATRPGTile.


I’m using this predicate function as an argument to the Heapify and HeapPop functions.


It compiles now, although I’m unsure if it functions correctly. For some reason overloading the < operator in my class doesn’t work by default. I also tried overloading the () operator by using two ATRPGTile& inputs, and that did not work either. Wondering if it is possible to get this working by overloading operators instead of using a predicate function.

I ran into this as well, I think we have to provide the function for comparison no matter what we do for the heap. I was using a TPriorityQueue wrapper for this, and unfortunately, I have to make this Blueprint accessible. Ill update if I find a better way than creating a function for this…