Announcement

Collapse
No announcement yet.

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

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    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:

    Code:
    //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...

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

    Code:
    TSet<AActor*>
    | Savior | USQLite | FSM | Object Pool | Sound Occlusion | Property Transfer | Magic Nodes | MORE |

    Comment


      #3
      .. I think you need to read the documentation for TSet: https://docs.unrealengine.com/en-US/...hitecture/TSet

      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.

      Comment

      Working...
      X