# TArray Find No operator found or suitable conversion

**URL:** <https://forums.unrealengine.com/t/tarray-find-no-operator-found-or-suitable-conversion/290577>\
**Category:** C++\
**Tags:** tarray, compilation-error, unreal-engine, find, question, CPP\
**Created:** [August 9, 2014, 11:48pm UTC](https://forums.unrealengine.com/t/tarray-find-no-operator-found-or-suitable-conversion/290577 "2014-08-09T23:48:14Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_958fa14f](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_958fa14f](https://forums.unrealengine.com/u/anonymous_user_958fa14f)\
**Post date:** [August 9, 2014, 11:48pm UTC](https://forums.unrealengine.com/t/tarray-find-no-operator-found-or-suitable-conversion/290577/1 "2014-08-09T23:48:14Z")

</div>

I created a custom struct called FItem. Then I declared an Array in my header:

> TArray\>FItem MyItems; (cant write the arrows here but they are done correctly in my code)

Then in my cpp

> 

```
FItem Temp;

MyItems.Find(Temp);

```

And I get the following compile error:

> Error 2 error C2678: binary ‘==’ : no operator found which takes a left-hand operand of type ‘const FItem’ (or there is no acceptable conversion)   
> Any ideas why this is happening?

---

<div class="post-metadata">

**Author:** ![Shadowriver](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Shadowriver](https://forums.unrealengine.com/u/Shadowriver)\
**Post date:** [August 10, 2014, 12:10am UTC](https://forums.unrealengine.com/t/tarray-find-no-operator-found-or-suitable-conversion/290577/2 "2014-08-10T00:10:53Z")

</div>

Where do you use == operator? you dont have in code you pasted, check the line that error is pointing to, considering it’s ==, it’s most likely “if” condition

---

<div class="post-metadata">

**Author:** ![Dieselhead](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Dieselhead](https://forums.unrealengine.com/u/Dieselhead)\
**Post date:** [August 10, 2014, 12:12am UTC](https://forums.unrealengine.com/t/tarray-find-no-operator-found-or-suitable-conversion/290577/3 "2014-08-10T00:12:53Z")

</div>

It’s in the Find() method

> **[TArray::Find](https://docs.unrealengine.com/5.0/en-US/API/Runtime/Core/Containers/TArray/Find/1/)**
>
> Finds element within the array.

---

<div class="post-metadata">

**Author:** ![iniside](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/iniside/32/866315_2.png) [@iniside](https://forums.unrealengine.com/u/iniside)\
**Post date:** [August 10, 2014, 12:13am UTC](https://forums.unrealengine.com/t/tarray-find-no-operator-found-or-suitable-conversion/290577/4 "2014-08-10T00:13:24Z")

</div>

I assumie that FItem is custom data struct.

You need to overload == operator inside it. Find assumes there is operator == which will compare two values.

[http://en.wikibooks.org/wiki/C%2B%2B\_Programming/Operators/Operator\_Overloading](http://en.wikibooks.org/wiki/C%2B%2B_Programming/Operators/Operator_Overloading)

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_958fa14f](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_958fa14f](https://forums.unrealengine.com/u/anonymous_user_958fa14f)\
**Post date:** [August 10, 2014, 3:36am UTC](https://forums.unrealengine.com/t/tarray-find-no-operator-found-or-suitable-conversion/290577/5 "2014-08-10T03:36:49Z")

</div>

Thank you VERY VERY VERY much! You didn’t only help me on this issue but made me realize the way to approach 2 or 3 problems I ran into earlier this week. Thanks!

---

<div class="post-metadata">

**Author:** ![Edregol](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Edregol](https://forums.unrealengine.com/u/Edregol)\
**Post date:** [May 8, 2015, 7:52pm UTC](https://forums.unrealengine.com/t/tarray-find-no-operator-found-or-suitable-conversion/290577/6 "2015-05-08T19:52:03Z")

</div>

Hi guys,

the same error occurs for me even though I have overwitten the == operator.

To visualise what I’ve done so far here are some code snippets:

I’ve defined the struct within its own .H file:

```
USTRUCT()
struct FInventoryItem
{
	GENERATED_USTRUCT_BODY()
	UPROPERTY()
	AActor* aItemActor;
	UPROPERTY()
	FText ftDescription;

	FInventoryItem()
	{
		aItemActor = NULL;
		ftDescription = NSLOCTEXT("test_english", "PickupText", "PickupText");
	}

	bool operator == (const FInventoryItem rhs)
	{
		if (aItemActor == rhs.aItemActor && ftDescription.EqualTo(rhs.ftDescription))
		{
			return true;
		}
		else return false;
	}
};

```

Within a saperate class header I’ve defined an array which contains these Items:

```
TArray<FInventoryItem> arrInventory; 

```

As soon as I call (within my .CPP):

```
arrInventory.Contains(AnotherFInventoryItem);

```

I get the compiler error :

```
binary '==' : no operator found which takes a left-hand operand of type 'const FInventoryItem' (or there is no acceptable conversion)

```

as well as:

```
could be 'bool FInventoryItem::operator ==(const FInventoryItem)' 
or 'bool operator ==(const FDialogueContextMapping &,const FDialogueContextMapping &)' 
or 'bool operator ==(const FDialogueContext &,const FDialogueContext &)'
...

```

So the compiler knows about my overwritten method but doesn’t use it. Any idea what I am missing?

---

<div class="post-metadata">

**Author:** ![Edregol](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Edregol](https://forums.unrealengine.com/u/Edregol)\
**Post date:** [May 10, 2015, 8:59am UTC](https://forums.unrealengine.com/t/tarray-find-no-operator-found-or-suitable-conversion/290577/7 "2015-05-10T08:59:46Z")

</div>

Well obviously the parameters of the overwritten operator weren’t correct.  
If I do it this way everything works just fine:  
bool operator==( const FInventoryItemStruct& Other ) const

---

<div class="post-metadata">

**Author:** ![Crefossus](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Crefossus](https://forums.unrealengine.com/u/Crefossus)\
**Post date:** [February 17, 2017, 1:00am UTC](https://forums.unrealengine.com/t/tarray-find-no-operator-found-or-suitable-conversion/290577/8 "2017-02-17T01:00:10Z")

</div>

Other methods in TArray can call Find such as RemoveSingle. Just happened to me and google sent me here.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_aaeb1bba1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_aaeb1bba1](https://forums.unrealengine.com/u/anonymous_user_aaeb1bba1)\
**Post date:** [January 22, 2021, 6:07pm UTC](https://forums.unrealengine.com/t/tarray-find-no-operator-found-or-suitable-conversion/290577/9 "2021-01-22T18:07:28Z")

</div>

Yes dude, Thank you so much. Remove() was the problem in my case!

---

<div class="post-metadata">

**Author:** ![Repin\_Design](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/repin_design/32/598391_2.png) [@Repin\_Design](https://forums.unrealengine.com/u/Repin_Design)\
**Post date:** [May 19, 2021, 5:48pm UTC](https://forums.unrealengine.com/t/tarray-find-no-operator-found-or-suitable-conversion/290577/10 "2021-05-19T17:48:55Z")

</div>

not working for me, i still get same error when i use .Contains() function in TArray, even if i write operator exac same way.
