You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
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 withbool defaulted
and one without, to be combined intobool 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.The text was updated successfully, but these errors were encountered: