Opened 13 years ago
Closed 13 years ago
#2994 closed Feature Requests (fixed)
default value output precision
Reported by: | anonymous | Owned by: | Vladimir Prus |
---|---|---|---|
Milestone: | Boost 1.39.0 | Component: | program_options |
Version: | Boost 1.38.0 | Severity: | Not Applicable |
Keywords: | Cc: | s.ochsenknecht@… |
Description
If I make an option like this: ("maxlength", po::value<double>(&MaxLength)->default_value(.1), "Maximum edge length to keep.")
The help message looks like this: --maxlength arg (=0.10000000000000001) Maximum edge length to keep.
It probably should default to fewer decimal points.
Attachments (1)
Change History (5)
by , 13 years ago
Attachment: | ticket2994.patch added |
---|
comment:1 by , 13 years ago
I'm afraid that a certain, hard coded, output precision wouldn't satisfy all users. But there as an overloaded version of default_value() which can be used to define the string representation of the default value:
("maxlength", po::value<double>(&MaxLength?)->default_value(.1, "0.1"), "Maximum edge length to keep.")
This string is then used for the help output. I would recommend to use this approach.
I attached a test case to show the usage of this functionality. Maybe documentation needs to be updated.
Please comment.
comment:2 by , 13 years ago
Cc: | added |
---|
comment:3 by , 13 years ago
BTW: For all other values (were no string representation of the default value is defined) boost::lexical_cast<>() is used.
comment:4 by , 13 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
test case