I need to make an optional argument with a default value in my function. Currently the signature looks something like this:
void func(int a, std::optional<int> b = 10)
and the function behaves in the following way:
func(15, 5); // works
func(15); // works
The question is: If I remove the explicit initialization for the optional argument, like this:
void func(int a, std::optional<int> b)
Then It seems like the signature of the function changes
func(15, 5); // works
func(15); // fails
Which makes me very confused about the purpose of the std::optional
in the first place. What is it good for if not for creating optional arguments?