Description
Two things could possibly be added that I thought were impossible before:
A templated function could be added that converts a default value to a string only if it can be converted, and otherwise returns an empty string. This would enable the two versions of add_option
overloads, one with bool defaulted
and one without, to be combined into bool defaulted=false
.
Second, the default string could instead be set as a lambda function that is stored in the Option. A new method, ->defaulted()
, would run that lambda function to produce the default string. This would make the old bool option obsolete and is much more readable (but still would probably need to be supported until something like CLI11 2.0, since it would be very common in code). The bool option would simply run ->defaulted()
on the option.
Maybe I'm missing something, but I think this could work...
I which I could use ->default
, but it's a C++ keyword.