4.24 C++ Transition Guide

Hi,

since 4.24 has deprecated GetComponentsByClass, does anyone have any clue how to write elegant oneliners when getting components? For example getting a count of components of certain type used to be quite trivial, but with the new method, it seems extremely overcomplicated and clumsy.

For example, previously:



int32 InstancerCount = GetComponentsByClass(UHierarchicalInstancedStaticMeshComponent::StaticClass()).Num();


Now:



TInlineComponentArray<UHierarchicalInstancedStaticMeshComponent*> Instancers;
GetComponents(Instancers);
int32 InstancerCount = Instancers.Num();


Am I missing something? This doesn’t feel right, because generally, changes are made towards more modern, cleaner code. Not backwards, towards the old C times of coding :confused: Having no ability to get array of components of specific class without the out parameter solution feels very limiting.