How to actually overload == so you can use FindByKey?

Can anybody here tell me how to overload the == operator in a USTRUCT that will actually compile so I can use TArray.FindByKey?

I have tried every single possible way and I cannot stop getting C2678.

It’s even worse than boost…


I figured it out. The error C2678 simply was not accurate to what the problem actually was.

For bonus internet points, someone else will have this same problem, and will find your question on Google, and … not know what to do, because you didn’t tell them.

Come on, don’t leave us wondering!

1 Like

It’s too embarassing! But OK, here ya go:

I accidentally defined the USTRUCT() inside my .cpp file, not the .h file.

For whatever reason, the compiler was puking on the overload, not the fact it was in the wrong file. After simply removing the overload and trying to compile doing a manual search, I got the correct ‘int not supported’ error on the GENERATED_USTRUCT_BODY() line…

1 Like

That would do it!
And don’t be embarrassed. Every single thing I’ve ever learned, I didn’t know before I learned it. And every mistake I’ve trained to avoid, I’ve made at least once (usually more than once.)
Sharing with the community not only makes the world a little better, because others can learn from you, but it serves as a record to yourself that “today, I learned a thing!”
I love it when that happens, so, thanks for sharing :smiley:

1 Like

Indeed, thank you for your kind words!

Additionally, I updated that reply to the solution, so that it can be easily seen :smiley: