I could set a default of -1 as I know the passed arg will not ever be -1 so as @Tim Parnell says this will tell me nothing has been passed.
I could but i’m not a fan of variants or rather I prefer to use them as little as possible. And with arguments you run the risk of passing a value which needs testing in the method then to ensure it is of the correct type.
Thanks folks, i think i will go for the -1 default.
Auto is safer since it does not allow implicit conversion. But the solution of the default value of -1 (or whichever other negative value such as -32,768) is probably the best one. Better use an integer to do the job of an integer
Thanks Michel. I tend to agree with using a hammer when you have a nail. An AUTO may satisfy the desire to check for a nil value though, which can’t be done on an integer.
Why not have one method that accepts a value and one that does not?
Then do the work accordingly. Or have the no parameter method call that parametered method with a calculated value.