How to parse function arguments, when all have default values and only some of them are used? Example: I have a function with several arguments with default values
void fun(string a="", int b=0, string c="", int d=0)
{
//parse used arguments somehow
}
I want to use it with different value of arguments, for example:
fun("foo", 10);
fun(10, 10);
How can I determine which arguments were used? Maximum value of arguments is known and order will be always the same. I do not want to run function like:
fun("", 3, "", 10);
And I cannot use variadic functions.
Any ideas?
Overload the function.
Then
fun(3, 10)
becomes equivalent tofun("", 3, "", 10)
.