Using TSet<> with custom classes... (operator overloading)?

Hi…

Hi… i´m trying to insert my Actors inside a TSet<> container… I imagine i need to overload ‘<’ operator on my Actor classes…

but what is the correct way to do it ?

this is what i have:




//h

UCLASS()
class PROJECTAPI AMyActor : public AActor

GENERATED_BODY()

public:
FString id = "Alpha";

friend bool operator<(const AMyActor &_leftHandActor, const AMyActor &_rightHandActor);


}

//cpp

bool operator<(const AMyActor &_leftHandActor, const AMyActor &_rightHandActor){
for (int x = 0; x < 32; x++){

if (_leftHandActor.id[x] < _rightHandActor.id[x])
return true;
else{
if (_leftHandActor.id[x] == _rightHandActor.id[x])
continue;
else
return false;
}
}
}


But this is not working… i´m pretty sure i´m badly overloading operator…

I have no idea what you’re trying to do O_o
TSets do support Actor pointers just fine:



TSet<AActor*>


… I think you need to read the documentation for TSet: TSet | Unreal Engine Documentation

I am extremely curious what brought you to the idea that you’d have to overload the less-than operator. Is it something about the TSet**<ClassName>** part of the syntax? I’m not exactly great with my C++, but that’s referring to a Template, not a less-than.