# C++ Error C2679: Binary '=': no operator found which takes right-hand operand of type 'TArray'

**URL:** <https://forums.unrealengine.com/t/c-error-c2679-binary-no-operator-found-which-takes-right-hand-operand-of-type-tarray/307930>\
**Category:** Character & Animation\
**Tags:** tarray, unreal-engine, generated, CPP, question\
**Created:** [February 24, 2015, 2:59pm UTC](https://forums.unrealengine.com/t/c-error-c2679-binary-no-operator-found-which-takes-right-hand-operand-of-type-tarray/307930 "2015-02-24T14:59:04Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![Rama](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/rama/32/882413_2.png) [@Rama](https://forums.unrealengine.com/u/Rama)\
**Post date:** [February 26, 2015, 2:38pm UTC](https://forums.unrealengine.com/t/c-error-c2679-binary-no-operator-found-which-takes-right-hand-operand-of-type-tarray/307930/5 "2015-02-26T14:38:20Z")

</div>

#Pass by Reference

This would go a lot smoother if you pass the array by reference like this:

```
//void return type, pass array by reference
void ARTSHUD::GetAllUnitsOfType(Faction, Type, TArray<UClass*>& returnArray)
{
  //current code, but remove the local variable called returnArray
}

```

now to use it:

```
  TArray Result;
    GetAllUnitsOfType(EFaction(Faction),EUnitType(Type), Result);

```

Not sure how you are using your macro but if you are declaring Result somewhere before you use your macro then you dont have to include it in the macro.

#Performance

This setup will have performance benefits for you!

Look up “C++ Return array by reference” to see why.

#Big Picture, Templates

It seems based on your function name that you really want a template function

I suggest template function + GetAllActorsOfClass

I have wikis on both of these subjects.

> **[A new, community-hosted Unreal Engine Wiki](https://forums.unrealengine.com/t/a-new-community-hosted-unreal-engine-wiki/141494)**
>
> After over a year in maintenance mode, the official Unreal Engine Wiki is now permanently offline. These resources now live on a new community-run Unreal Engine Community Wiki — ue4community.wiki! You will be able to find content from the official...

[A new, community-hosted Unreal Engine Wiki - Announcements - Unreal Engine Forums](https://wiki.unrealengine.com/Iterators:)_Object_%26\_Actor\_Iterators,\_Optional\_Class\_Scope\_For\_Faster\_Search

My solution is based on you wanting to find runtime instances of your units, not entirely sure if that’s your goal or not, if not, then the pass by ref solution should help you 🙂

Enjoy!

Rama

---

_[View the full topic](https://forums.unrealengine.com/t/c-error-c2679-binary-no-operator-found-which-takes-right-hand-operand-of-type-tarray/307930)._
