Can You test to compile the following code if to figure our what I am doing wrong?
you can test it without and with blueprint libraries, both gives the same error.
int32 Index;
FTransform Location;
TArray<FTransform> TransformArray;
bool bEqualValid ;
//Randomizing the array and subtract -1 index from the array
index = FMath::RandRange(0, TransformArray.Num() - 1);
Index = FCustomThunkTemplates::Array_Find(TransformArray, Transform); //this function causing the operator overload error.
bEqualValid = UKismetMathLibrary::EqualEqual_IntInt(Index, -1); //this function causing the operator overload error.
I have problem with this from few days, in blueprints it works perfectly, Since FTransform has no == I won’t be able to use the normal methods of finding the index.
Yes I found that channel yesterday and joined they are not able to help, they want me to use vector array, but I want to use transform array, transform has no == operator
Free operator==() is added OUTSIDE of class scope.
You should add it in some header, outside of the definition of any class.
Also, defining an equality operator for transforms in the way you suggest, would not pass code review for me – it will lead to hard to reason about bugs, because someone will assume it test for actual equality, and “most of the time” it will “work fine.”
Use the equality operator only for cases of strict equality. Add some wrapper function for other kinds of tests. Or, just code in the GetLocation() on each side when that is what you mean – it’s like 20 characters to type, and it’s much clearer to read and understand what’s being tested.
this is not a troll, this is actually I am showing her to stop what she is doing, overloading operator will still not help her since she is comparing float random offsets, the only thing can help her is this Post in her case of do/while loop || ContainsByPredicate.