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

store_into overload for bools assumes turning into a flag, which isn't correct for certain use cases #379

Open
Xottab-DUTY opened this issue Sep 13, 2024 · 0 comments

Comments

@Xottab-DUTY
Copy link

Reproduction code:

struct options
{
    bool my_opt{ true }
};

program.add_argument("-opt")
    .store_into(options.my_opt);

Here, store_into calls flag function, and then store_into sets the options.my_opt value to false, making initial value lost.

The use case is that I want to provide the recommended defaults for all the application options with the ability to override them. That means, some bool variables can be true by default instead of false and can be overridden with -opt=false syntax. This isn't possible with flags, and store_into for bools assumes exactly flags. This assumption is quite not for everyone.

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

1 participant