I have an array of ParticleSystemComponent pointers that I am trying to sort by name (in my test code the sorter always returns true).
// my sorting function
inline static bool WeaponMuzzleSort(const UParticleSystemComponent One, const UParticleSystemComponent Two)
{
return true;
}
// my calling code
TArray<UParticleSystemComponent*>& MFArray;
MFArray.Sort(WeaponMuzzleSort);
When I attempt to compile this code I get the following error:
//...
25>D:\Develop\Sandman\root\UE4\Engine\Source\Runtime\Core\Public\Templates\Sorting.h(51): error C2248: 'UParticleSystemComponent::UParticleSystemComponent' : cannot access private member declared in class 'UParticleSystemComponent'
25> D:\Develop\Sandman\root\UE4\Engine\Source\Runtime\Engine\Classes\Particles/ParticleSystemComponent.h(253) : see declaration of 'UParticleSystemComponent::UParticleSystemComponent'
25> D:\Develop\Sandman\root\UE4\Engine\Source\Runtime\Engine\Classes\Particles/ParticleSystemComponent.h(251) : see declaration of 'UParticleSystemComponent'
25> D:\Develop\Sandman\root\UE4\Engine\Source\Runtime\Core\Public\Templates\Sorting.h(50) : while compiling class template member function 'bool TDereferenceWrapper<T *,PREDICATE_CLASS>::operator ()(T *,T *) const'
25> with
25> [
25> T=UParticleSystemComponent
25> , PREDICATE_CLASS=bool (UParticleSystemComponent,UParticleSystemComponent)
25> ]
25> D:\Develop\Sandman\root\UE4\Engine\Source\Runtime\Core\Public\Templates\Sorting.h(90) : see reference to function template instantiation 'bool TDereferenceWrapper<T *,PREDICATE_CLASS>::operator ()(T *,T *) const' being compiled
25> with
//...
It appears that the issue is that UParticleSystemComponent has a private constructor (as defined in the macro GENERATED_UCLASS_BODY()) and the Sort function needs a public constructor in order to work.
This seems like a super routine problem (sorting an array of components) so I was wondering if there is any quick code solutions for this other than manually looping through the array and shuffling it around.