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

Allow setting dynamic sets of argument choices #368

Open
tlemo opened this issue Jul 16, 2024 · 0 comments
Open

Allow setting dynamic sets of argument choices #368

tlemo opened this issue Jul 16, 2024 · 0 comments

Comments

@tlemo
Copy link

tlemo commented Jul 16, 2024

Currently, the .choices(...) method require passing the list of choices as individual arguments. This works well when the list of choices is known statically, but if the list is dynamic (ex. computed into a std::vector<T>), setting the choices becomes unnecessarily verbose (you'd have to loop over the values and call .add_choice() for each one).

Unfortunately, the variadic .choices(...) interface prevents overloading, so the suggestion is to add a new method along the lines of:

template<class T>
Argument& choices_list(const T& list) {
  for (const auto& v : list) {
   add_choice(v);
  }
  return *this;
}
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