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

potential issues with default_val call #371

Closed
phlptp opened this issue Dec 16, 2019 · 1 comment
Closed

potential issues with default_val call #371

phlptp opened this issue Dec 16, 2019 · 1 comment
Milestone

Comments

@phlptp
Copy link
Collaborator

phlptp commented Dec 16, 2019

In looking at #369. There are a few potential issues with using that function.

It actually evaluates the callback, which works perfectly fine if CLI11 is assigning to a variable or the callback is empty. In that context that is probably the correct thing to do. But if the callback was user specified this could result in very unexpected behavior such as repeat callbacks or oddly timed callbacks if there was user defined dependencies.

I am wondering if there needs to be a flag set up in the option definition that can discriminate between some of the CLI11 defined callbacks and user defined one and the function callback, so those user defined callbacks are not called at unexpected times.

Also wondering if default_val should be a template that can take any type(that can be converted to a string), so if you had an option taking an integer you could do

opt->default_val(5);
@henryiii
Copy link
Collaborator

We could add such a flag.

Yes, we could add a template to that function. I originally did not because I thought we were going to add a template to Option at some point; I'm now rather thinking we will not, since by avoiding (public) templated classes we can precompile and same some time.

This was referenced Dec 30, 2019
@henryiii henryiii added this to the v1.9 milestone Dec 31, 2019
@phlptp phlptp closed this as completed Jan 3, 2020
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