Can I cast FScriptArray to TArray?
Is good this practice casting FScriptArray to TArray if I'm sure that UProperty has array defined as specified TArray template?
TArray and FScriptArray are not interconnected by inheritance or something else. But has similar allocation in memory (as trick). Me right?
asked Aug 31 '17 at 12:29 PM in C++ Programming
TArray and FScriptArray are layout compatible, and are required as a basis for the property system. There is also FScriptMap, FScriptSet and FScriptSparseArray which are layout compatible with TMap, TSet and TSparseArray respectively.
However, while it's always going to be the case that these FScript* classes have this compatibility, it's generally not recommended to use them, as they are more an implementation detail of the UE4 reflection system. Correctly reading and manipulating elements within containers and honouring object lifetimes is considerably more involved than just casting to those classes and using them. What is your use case?
answered Aug 31 '17 at 01:05 PM
Steve Robb STAFF
I can't comment answers on my question, so I post comment as answer for you, Steve Robb.
My case is serialization exception where I serializing specific struct with TArray field. I need to get this field as TArray:
answered Sep 04 '17 at 12:24 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here