# Binary ‘==’: no operator found? FTransform == FTransform

**URL:** <https://forums.unrealengine.com/t/binary-no-operator-found-ftransform-ftransform/628457>\
**Category:** C++\
**Tags:** UE4-20, unreal-engine, UE4, CPP, question\
**Created:** [August 14, 2022, 11:25pm UTC](https://forums.unrealengine.com/t/binary-no-operator-found-ftransform-ftransform/628457 "2022-08-14T23:25:26Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alexa.Ki](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/alexa.ki/32/562753_2.png) [@Alexa.Ki](https://forums.unrealengine.com/u/Alexa.Ki)\
**Post date:** [August 14, 2022, 11:25pm UTC](https://forums.unrealengine.com/t/binary-no-operator-found-ftransform-ftransform/628457/1 "2022-08-14T23:25:26Z")

</div>

I am already trying some code which is not working, correct me what I am doing wrong? please check the blueprint version of this code and correct me if I am doing wrong something.

| Severity | Code | Description | File | | | |
| --- | --- | --- | --- | --- | --- | --- |
| Error | C2678 | binary ‘==’: no operator found which takes a left-hand operand of type ‘const FTransform’ (or there is no acceptable Conversion] | Array.h | | | |

> My Code

```auto
ItemGroupRef->GetAllTransforms(Available);
RandomLocation(Available, Location); 
if (UsedLocations.Find(Location) == -1) //issue happening here
{
   //Some codes
}

```

blueprint example"

 ![image_2022-08-15_042015387](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/a/c/3ac2f8bfc53e6dcea35c0201df908c5fc377f317.png)

i don’t know why the native bp code for this logic is using `89` switch cases 😃

 ![image_2022-08-15_070940159](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/0/0/b0032084e6f160960e37508f908c15db90697b99.png)

---

<div class="post-metadata">

**Author:** ![JoSf](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@JoSf](https://forums.unrealengine.com/u/JoSf)\
**Post date:** [August 15, 2022, 1:54am UTC](https://forums.unrealengine.com/t/binary-no-operator-found-ftransform-ftransform/628457/2 "2022-08-15T01:54:14Z")

</div>

> **[TArray: Arrays in Unreal Engine](https://docs.unrealengine.com/4.27/en-US/ProgrammingAndScripting/ProgrammingWithCPP/UnrealArchitecture/TArrays/)**

```auto
int32 Index;
if (StrArr.Find(TEXT("Hello"), Index))
{
    // Index == 3
}

```

---

<div class="post-metadata">

**Author:** ![Alexa.Ki](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/alexa.ki/32/562753_2.png) [@Alexa.Ki](https://forums.unrealengine.com/u/Alexa.Ki)\
**Post date:** [August 15, 2022, 2:02am UTC](https://forums.unrealengine.com/t/binary-no-operator-found-ftransform-ftransform/628457/3 "2022-08-15T02:02:46Z")

</div>

Hi, You think your answer makes sense if you compare it to what I am doing?

---

<div class="post-metadata">

**Author:** ![Roy\_Wierer.Seda145](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/roy_wierer.seda145/32/906551_2.png) [@Roy\_Wierer.Seda145](https://forums.unrealengine.com/u/Roy_Wierer.Seda145)\
**Post date:** [August 15, 2022, 2:51am UTC](https://forums.unrealengine.com/t/binary-no-operator-found-ftransform-ftransform/628457/4 "2022-08-15T02:51:27Z")

</div>

FTransform does not have a == operator:

> \UE\_4.27\Engine\Source\Runtime\Core\Public\Math\TransformNonVectorized.h

For some reason it is commented out. You can do your own comparisons on the Location / Rotation / Scale structs within the transform struct.

```auto
bool operator==(const FTransform& Other) const
{
  return (
    Rotation == Other.Rotation
    && Translation == Other.Translation 
    && Scale3D == Other.Scale3D;  
  );

}

```

---

<div class="post-metadata">

**Author:** ![Alexa.Ki](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/alexa.ki/32/562753_2.png) [@Alexa.Ki](https://forums.unrealengine.com/u/Alexa.Ki)\
**Post date:** [August 15, 2022, 2:56am UTC](https://forums.unrealengine.com/t/binary-no-operator-found-ftransform-ftransform/628457/5 "2022-08-15T02:56:02Z")

</div>

So this limitation is only for C++?  
What about blueprint, the branch is not using the `==` ?

---

<div class="post-metadata">

**Author:** ![Roy\_Wierer.Seda145](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/roy_wierer.seda145/32/906551_2.png) [@Roy\_Wierer.Seda145](https://forums.unrealengine.com/u/Roy_Wierer.Seda145)\
**Post date:** [August 15, 2022, 2:58am UTC](https://forums.unrealengine.com/t/binary-no-operator-found-ftransform-ftransform/628457/6 "2022-08-15T02:58:53Z")

</div>

I believe there is some “magic” going on behind the scenes for blueprint types to automate operators. It is a limitation in c++ however. c++ types must have operators defined if you want to use the operators.

If you find a missing operator in c++ you’d have to modify engine source to implement it. An alternative is to implement your own library using static methods to implement the logic.

---

<div class="post-metadata">

**Author:** ![Alexa.Ki](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/alexa.ki/32/562753_2.png) [@Alexa.Ki](https://forums.unrealengine.com/u/Alexa.Ki)\
**Post date:** [August 15, 2022, 3:02am UTC](https://forums.unrealengine.com/t/binary-no-operator-found-ftransform-ftransform/628457/7 "2022-08-15T03:02:51Z")

</div>

please guide me how to add static method to make it work for my logic.  
I am afraid if I modify the engine code, it will recompile the whole engine takes 6hrs.

---

<div class="post-metadata">

**Author:** ![Roy\_Wierer.Seda145](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/roy_wierer.seda145/32/906551_2.png) [@Roy\_Wierer.Seda145](https://forums.unrealengine.com/u/Roy_Wierer.Seda145)\
**Post date:** [August 15, 2022, 3:11am UTC](https://forums.unrealengine.com/t/binary-no-operator-found-ftransform-ftransform/628457/8 "2022-08-15T03:11:19Z")

</div>

Yes you should probably not work on engine source, waste of time.  
Since you shouldn’t need it for blueprints you should just be fine with a simple library:

```auto
YourUtils.h

```

```auto
#pragma once

#include "Math/TransformNonVectorized.h"

class FYourUtils {

public:

	static bool IsEqual_Transform(const FTransform& A, const FTransform& B);

};

```

> YourUtils.cpp

```auto
#include "YourUtils.h"

bool FYourUtils::IsEqual_Transform(const FTransform& A, const FTransform& B) {
  return (
    A.Rotation == B.Rotation
    && A.Translation == B.Translation 
    && A.Scale3D == B.Scale3D
  );  
}

```

---

<div class="post-metadata">

**Author:** ![Alexa.Ki](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/alexa.ki/32/562753_2.png) [@Alexa.Ki](https://forums.unrealengine.com/u/Alexa.Ki)\
**Post date:** [August 15, 2022, 3:15am UTC](https://forums.unrealengine.com/t/binary-no-operator-found-ftransform-ftransform/628457/9 "2022-08-15T03:15:05Z")

</div>

Thank you very much Sir for solving this strange issue, extremely appreciated 🙂

---

<div class="post-metadata">

**Author:** ![Alexa.Ki](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/alexa.ki/32/562753_2.png) [@Alexa.Ki](https://forums.unrealengine.com/u/Alexa.Ki)\
**Post date:** [August 15, 2022, 4:19am UTC](https://forums.unrealengine.com/t/binary-no-operator-found-ftransform-ftransform/628457/10 "2022-08-15T04:19:43Z")

</div>

Sir one more question, where I will find this `Utils.h` and `Utils.cpp` to write this code in it?

---

<div class="post-metadata">

**Author:** ![Roy\_Wierer.Seda145](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/roy_wierer.seda145/32/906551_2.png) [@Roy\_Wierer.Seda145](https://forums.unrealengine.com/u/Roy_Wierer.Seda145)\
**Post date:** [August 15, 2022, 6:14am UTC](https://forums.unrealengine.com/t/binary-no-operator-found-ftransform-ftransform/628457/11 "2022-08-15T06:14:36Z")

</div>

You make them in your /Source/ folder of your project and compile it with Visual Studio as usual.

---

<div class="post-metadata">

**Author:** ![Ares9323](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/ares9323/32/1194521_2.png) [@Ares9323](https://forums.unrealengine.com/u/Ares9323)\
**Post date:** [August 15, 2022, 6:14am UTC](https://forums.unrealengine.com/t/binary-no-operator-found-ftransform-ftransform/628457/12 "2022-08-15T06:14:41Z")

</div>

You should never compare FVectors and FRotators with ==, because sometimes the engine approximates the float values and it would return false (the most common case, for example, is when you set 90° and it shows 89.99999° or similar values, don’t know why but it happens very frequently to me both in FVectors and FRotators)

The recommended way to compare two transforms is to use [UKismetMath::NearlyEqual\_TransformTransform](https://docs.unrealengine.com/4.26/en-US/API/Runtime/Engine/Kismet/UKismetMathLibrary/NearlyEqual_TransformTransform/)

This function also exists for vector and rotators and allows you to pass the tolerance for each value as parameter

---

<div class="post-metadata">

**Author:** ![Roy\_Wierer.Seda145](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/roy_wierer.seda145/32/906551_2.png) [@Roy\_Wierer.Seda145](https://forums.unrealengine.com/u/Roy_Wierer.Seda145)\
**Post date:** [August 15, 2022, 6:27am UTC](https://forums.unrealengine.com/t/binary-no-operator-found-ftransform-ftransform/628457/13 "2022-08-15T06:27:27Z")

</div>

That is true. Unsure why the engine turns exact 90 into something else but I’ve seen it happen on the editor. Magic float precision. The == operator is however implemented on FVector and FRotator like this:

```auto
FORCEINLINE bool FVector::operator==(const FVector& V) const
{
	return X==V.X && Y==V.Y && Z==V.Z;
}

FORCEINLINE bool FRotator::operator==( const FRotator& R ) const
{
	return Pitch==R.Pitch && Yaw==R.Yaw && Roll==R.Roll;
}

```

You can use the kismet library to get the precision right with blueprints. All it does is call 3 methods on FTransform accessible in c++, which in turn call similar methods on the vectors:

```auto
FTransform::AreRotationsEqual(A, B, RotationTolerance) &&
FTransform::AreTranslationsEqual(A, B, LocationTolerance) &&
FTransform::AreScale3DsEqual(A, B, Scale3DTolerance);

```

---

<div class="post-metadata">

**Author:** ![Alexa.Ki](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/alexa.ki/32/562753_2.png) [@Alexa.Ki](https://forums.unrealengine.com/u/Alexa.Ki)\
**Post date:** [August 15, 2022, 1:02pm UTC](https://forums.unrealengine.com/t/binary-no-operator-found-ftransform-ftransform/628457/14 "2022-08-15T13:02:29Z")

</div>

Ok I created an empty class `MyUtils` using the editor and can’t access `TransformNonVectorized`

| Severity | Code | Description | Project | | | |
| --- | --- | --- | --- | --- | --- | --- |
| Error (active) | E0265 | member FTransform::Rotation (declared at line 42 of Public\Math/TransformVectorized.h) is inaccessible | MyGame | | 11 | |

MyUtils.h

```auto
#pragma once
#include "CoreMinimal.h"
#include "Math/TransformNonVectorized.h"

class MyGame_API MyUtils
{
public:
	static bool IsEqual_Transform(const TArray<FTransform>& A, const FTransform& B);
};

```

MyUtils.cpp

```auto
#include "MyUtils.h"

bool MyUtils::IsEqual_Transform(const TArray<FTransform>& A, const FTransform& B))
{
	return (
		A.Rotation == B.Rotation
		&& A.Translation == B.Translation
		&& A.Scale3D == B.Scale3D
		);
}

```

---

<div class="post-metadata">

**Author:** ![Alexa.Ki](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/alexa.ki/32/562753_2.png) [@Alexa.Ki](https://forums.unrealengine.com/u/Alexa.Ki)\
**Post date:** [August 15, 2022, 3:42pm UTC](https://forums.unrealengine.com/t/binary-no-operator-found-ftransform-ftransform/628457/15 "2022-08-15T15:42:20Z")

</div>

this is where it takes me along with compile time error. `Array.h`

 ![image_2022-08-15_204058223](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/a/28a03c45e22fbdeeac78b64682b898a3bbf1c066.png)

---

<div class="post-metadata">

**Author:** ![GigiK-K-K](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@GigiK-K-K](https://forums.unrealengine.com/u/GigiK-K-K)\
**Post date:** [August 15, 2022, 5:52pm UTC](https://forums.unrealengine.com/t/binary-no-operator-found-ftransform-ftransform/628457/16 "2022-08-15T17:52:39Z")

</div>

just my guess

```auto
"Location_"

```

is not a integer or has other things besides integers there for you are trying to convert something to an integer number like a float maybe or evens something else.

FTransform is a float ? and “-1” is an integer number.

---

<div class="post-metadata">

**Author:** ![Alexa.Ki](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/alexa.ki/32/562753_2.png) [@Alexa.Ki](https://forums.unrealengine.com/u/Alexa.Ki)\
**Post date:** [August 15, 2022, 5:56pm UTC](https://forums.unrealengine.com/t/binary-no-operator-found-ftransform-ftransform/628457/17 "2022-08-15T17:56:28Z")

</div>

`Location` is of type `FTransform`  
in this post the full snippet can be found [Snippet](https://forums.unrealengine.com/t/help-correct-me-converting-blueprint-into-c/628877)

---

<div class="post-metadata">

**Author:** ![GigiK-K-K](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@GigiK-K-K](https://forums.unrealengine.com/u/GigiK-K-K)\
**Post date:** [August 15, 2022, 5:59pm UTC](https://forums.unrealengine.com/t/binary-no-operator-found-ftransform-ftransform/628457/18 "2022-08-15T17:59:22Z")

</div>

Transform composed of Scale, Rotation (as a quaternion), and Translation.

> **[FTransform](https://docs.unrealengine.com/4.26/en-US/API/Runtime/Core/Math/FTransform/)**
>
> Transform composed of Scale, Rotation (as a quaternion), and Translation.

Transforms can be used to convert from one space to another, for example by transforming positions and directions from local space to world space.

So it’s based on float values if I’m not mistaken, to convert possition from local to world and those values are based on floats.

== may not work with floats, I never tried using floats with it and -1 looks like an integer.

---

<div class="post-metadata">

**Author:** ![GigiK-K-K](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@GigiK-K-K](https://forums.unrealengine.com/u/GigiK-K-K)\
**Post date:** [August 15, 2022, 6:04pm UTC](https://forums.unrealengine.com/t/binary-no-operator-found-ftransform-ftransform/628457/19 "2022-08-15T18:04:00Z")

</div>

one click search says.

[https://www.cs.technion.ac.il/users/yechiel/c++-faq/floating-point-arith.html](https://www.cs.technion.ac.il/users/yechiel/c++-faq/floating-point-arith.html)  
Because floating point arithmetic is different from real number arithmetic.

Bottom line: Never use == to compare two floating point numbers.

Here’s a simple example:

So my hunch turned right. == is for exact float match in your case, probally why. But it’s not usable in this case.

---

<div class="post-metadata">

**Author:** ![Alexa.Ki](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/alexa.ki/32/562753_2.png) [@Alexa.Ki](https://forums.unrealengine.com/u/Alexa.Ki)\
**Post date:** [August 15, 2022, 6:08pm UTC](https://forums.unrealengine.com/t/binary-no-operator-found-ftransform-ftransform/628457/20 "2022-08-15T18:08:54Z")

</div>

I am not comparing two floating points , I have the stored locations in data table  
 ![image_2022-08-15_230640340](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/d/b/3dbf903ba78b1002dd7dd928d5fb3551a6a8d503.png)

I am looping through these filxed locations, if a location/row is duplicated , I remove it by -1 to randomize it again. these are spawn locations.  
these are assigned in `getalltransforms` function

[Next page](https://forums.unrealengine.com/t/binary-no-operator-found-ftransform-ftransform/628457.md?page=2)
