Is there a way to change how boost::program_options formats the default value of the options in the help text of a program_options::options_description
(that one can obtains through cout << description
)? In particular I have default values which are floats, so the usual decimal-to-binary conversion gives me a help text that looks like --arg (0.100000001)
which is quite ugly.
Using cout << setprecision(4)
doesn't work because program_options is <<
'ing itself the default values to some internal streams to do the formatting first (at least that's what I inferred by looking at the source code), and what gets <<
'ed to cout
is the resulting string(stream?).
Thanks.
Call the two-argument version of default_value
. Then you can specify a string version of the value, and that will get printed instead of trying to print the given value with <<
.