# How to make weak object pointer to UINTERFACE-derived class?

**URL:** <https://forums.unrealengine.com/t/how-to-make-weak-object-pointer-to-uinterface-derived-class/370581>\
**Category:** UI\
**Tags:** garbage-collector, interface, unreal-engine, UI, UE4, CPP, question\
**Created:** [September 15, 2016, 8:37pm UTC](https://forums.unrealengine.com/t/how-to-make-weak-object-pointer-to-uinterface-derived-class/370581 "2016-09-15T20:37:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_f6ad20b4](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_f6ad20b4](https://forums.unrealengine.com/u/anonymous_user_f6ad20b4)\
**Post date:** [September 15, 2016, 8:37pm UTC](https://forums.unrealengine.com/t/how-to-make-weak-object-pointer-to-uinterface-derived-class/370581/1 "2016-09-15T20:37:48Z")

</div>

It is my impression that an array of GC-aware references to C++ implementations of an Unreal Interface class (declared with UINTERFACE, etc) can be made like so:

```
UPROPERTY()
TArray<TScriptInterface<ISomeUnrealInterface>>

```

And that an array of GC-Aware _weak_ references to any old UObject can be made like so (notably without any UPROPERTY macro):

```
TArray<TWeakObjectPtr<USomeUnrealObject>>

```

But I am left a bit flummoxed as to how one would make an array of GC-aware weak pointers to unreal interfaces. Is it even possible?

---

<div class="post-metadata">

**Author:** ![bstone](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@bstone](https://forums.unrealengine.com/u/bstone)\
**Post date:** [March 13, 2019, 4:07pm UTC](https://forums.unrealengine.com/t/how-to-make-weak-object-pointer-to-uinterface-derived-class/370581/2 "2019-03-13T16:07:56Z")

</div>

For anyone looking for an answer to this old question, check TWeakInterfacePtr\<\> out. It’s defined in GameplayTaskTypes.h

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_f6ad20b4](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_f6ad20b4](https://forums.unrealengine.com/u/anonymous_user_f6ad20b4)\
**Post date:** [April 9, 2019, 10:04pm UTC](https://forums.unrealengine.com/t/how-to-make-weak-object-pointer-to-uinterface-derived-class/370581/3 "2019-04-09T22:04:10Z")

</div>

Well, I for one am satisfied to have an answer, even if the project it was for has long ago been laid at peace. I will try to test this and accept the answer if I have the time (Though I may end up forgetting—I’m not even working on anything in Unreal at this exact moment).

---

<div class="post-metadata">

**Author:** ![FunGames55](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/fungames55/32/710746_2.png) [@FunGames55](https://forums.unrealengine.com/u/FunGames55)\
**Post date:** [June 15, 2022, 1:30am UTC](https://forums.unrealengine.com/t/how-to-make-weak-object-pointer-to-uinterface-derived-class/370581/4 "2022-06-15T01:30:56Z")

</div>

> [@bstone](#):
>
> TWeakInterfacePtr

One thing to note is TWeakInterfacePtr does not propagate cv qualifiers of the template type. Didn’t have this issue with TWeakObjectPtr. So `TWeakInterfacePtr<const IMyInterface>` won’t compile. I had to use `TWeakInterfacePtr<IMyInterface>` and cast away the constness with a `const_cast<IMyInterface*>` prior to invoking the TWeakInterfacePtr constructor.
