I did a little digging in the UE github thinking I could find one of those nodes that return a ref but was unsuccessful (also the Get by ref node doesn’t do anything when double clicked) so some UE trickery may be afoot.
Anyway it seems for TArray they just return refs and pointers, which works in C++ just fine as we discussed in this thread, but I see nothing in the code that actually links to BP. So some sort of bridge/interface must be used somewhere where they doe their magic.
// UnrealEngine/Engine/Source/Programs/UnrealTraceServer/src/Foundation.h
template <typename Type>
struct TArray
: protected std::vector<Type>
{
// other code...
Type* GetData() { return &(this->operator [] (0)); }
const Type* GetData() const { return &(this->operator [] (0)); }
}
// UnrealEngine/Engine/Source/Runtime/Core/Public/Containers/Array.h
template<typename InElementType, typename InAllocatorType>
class TArray
{
// a lot of other code ...
FORCEINLINE ElementType* GetData() UE_LIFETIMEBOUND
{
return (ElementType*)AllocatorInstance.GetAllocation();
}
FORCEINLINE ElementType& operator[](SizeType Index) UE_LIFETIMEBOUND
{
RangeCheck(Index);
return GetData()[Index];
}
FORCEINLINE ElementType& Last(SizeType IndexFromTheEnd = 0) UE_LIFETIMEBOUND
{
RangeCheck(ArrayNum - IndexFromTheEnd - 1);
return GetData()[ArrayNum - IndexFromTheEnd - 1];
}
}
(I could not find the source of AllocatorInstance)
Don’t know if this is actually helpful but I just wanted to add this to the thread in case anyone wants to dig further.