Hey for one of the functions in my class Mesh Generator I need to create a function that can take a variable number of parameters. After looking through documention it seems like the best way to do this for a variable number of parameters with the same type is using std::initializer_list. Note: I have included the #include as well. Here is the declaration of the function:
Now the code doesn’t have any errors when hovering over it and seems to recognise intializer_list but upon compiling I’m getting this error on that function declaration:
Cannot find class '', to resolve delegate 'initializer_list'
I’ve tried searching this error online but there seems to be literally no mention of it anywhere so I’m unsure of whether this is due to UE4 or purely a C++ problem.
If anyone knows any other way of getting around this and allowing for a variable number of parameters it would be greatly appreciated.
If you want compile-time-sized arrays without dynamic memory allocation, you can try to use a fixed allocator with TArray. Then you can populate it as such:
Sorry I’m not 100% clear on what you mean by this? For clarification my goal is to have a function call that takes a varied number of arguments. So for example I only have 1 function declaration like:
Thinking about it, it would probably make sense to make a temporary array of points that are sent through to the function but since the function call is in a for loop that will most likely loop around 1000x times I get the impression that this wouldn’t be very efficient?
I was about to make the suggestion of using an array myself. You can populate a TArray with the points necessary and pass that into your function. Unless you are manipulating physics assets or spawning new actors inside the function or doing other extensive processes, it shouldn’t cause a problem to use this method.