How to pass a NULL or empty Tarray to a function expecting one as a param?

Howdy folks,

So I’m having a bit of trouble finding a way to do this. I have a function that accepts a TArray as a param. However, there are some times when I call this function but do not wish to pass any data into the TArray, thus I’d like to pass NULL or some equivalent. When I try to pass Null as the parameter, I get

“error C2664: ‘void myfunction(TArray)’ : cannot convert argument
No consturctor could take the source type, or consturctor overload resolution was ambiguous”

A bit of background, this is code I’m converting from another language for work so I’m trying to keep it as close to source as possible. Source of the code was written in ActionScript 3.

So my question is, is there a way to pass a Null to the TArray as the target function does a check to see if the array is null or not?

A solution I came up with was to make another TArray that never gets used and thus should be ‘empty’ and just use that in place of the Null and to check it’s .Num() method instead of the ‘null’ check already present in the code. But I’m not sure if that is optimal or not.

If someone needs a code sample, I can whip up a dummy version of what I’m doing to help.

Thanks in advance.

EDIT: 2/3/2015
I’d like to thank ScottSpadea for his useful info of Overloads. I had forgotten all about them. While that would work if this was the only issue, I found there was more to this code.

The function I am referring too above is being funneled to a sort of translator struct in another file. There are several other files with similar functions to the one above and just different names / different operations based on what the file is for. The overall project is dealing with different printer devices that we support. Most will have a lot of code that is similar except for a few lines and such depending on the manufacturer specifications and such. I know that we could just use encapsulation and make some base/derived classes and fix the need for a translator struct but, as stated before, the higher ups want to keep the code as close to source as possible.

So far the empty TArray I came up with seems to be working but it just feels like there should be some other way to do this. Sorry if I ramble.

have you tried making an overloaded version of the function that doesn’t use TArray as an input?

just make a second definition for your function, but change the arguments to remove the array.

Holy crap I forgot all about overloads. That is a good idea but I don’t think I can use it. When I was looking at the code to see if your idea would work, I found that this function an a few others are put into a sort of translation struct later on so they all have the same name. I know we could just make a base class and derive others from it to get around that but, as stated, higher ups want to try and keep the code as close to source as possible. I’ll edit my original post with this new info.
Thank you for reminding me of overloads though. Might help on some other stuff in this monster code.

Ended up just creating an empty TArray const and using that for situations where it was mandatory due to old code recreation. I was able to get the higher ups to let me rewrite some of this to use inheritance so that fixed a lot of it. Thanks again.