Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting default values do not take effect #26

Closed
xieepp opened this issue Aug 31, 2017 · 4 comments
Closed

Setting default values do not take effect #26

xieepp opened this issue Aug 31, 2017 · 4 comments

Comments

@xieepp
Copy link

xieepp commented Aug 31, 2017

int test = 0;  
app->add_option("--test", test, "Test the default value.")->set_default_val(std::to_string(200));  
app->parse(argc, argv);
std::cout << test << endl; // output:0, want: 200
@henryiii
Copy link
Collaborator

That's because set_default_val sets the default value string, the initial value is set by

int test = 200;

Would it be best to change set_default_val to set_default_str to make it clearer, or is there a use case for actually having it evaluate the default value string, either immediately (easier) or when it parses (harder to implement cleanly)?

@xieepp
Copy link
Author

xieepp commented Sep 1, 2017

I think evaluate immediately would be enough~

@henryiii
Copy link
Collaborator

henryiii commented Sep 2, 2017

Let me know if that fixed it for you!

@xieepp
Copy link
Author

xieepp commented Sep 4, 2017

Works fine, thanks very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants