You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Suppose I define a non-boolean option of type T, without a default value, using cxxopts.
I can't obtain this option using just cxxopts::ParseResults::as<T>() - because that might throw. Instead, I have to first use count(), like in the README example code:
if (result.count("bar"))
bar = result["bar"].as<std::string>();
This is somewhat redundant. Why do I have to say "bar" twice? ... instead, I should be able to write:
auto bar = result["bar"].as<std::optional<std::string>>()
and get an optional which is nullopt if bar wasn't specified, and a boxed actual string if it was.
Bonus points if you support std::experimental::optional when C++14 is used.
The text was updated successfully, but these errors were encountered:
@jarro2783 : An alternative, or an addition, to this, which would be "breaking", is changing as<T> so that it always returns an optional<T>, and never throws.
Suppose I define a non-boolean option of type T, without a default value, using cxxopts.
I can't obtain this option using just
cxxopts::ParseResults::as<T>()
- because that might throw. Instead, I have to first usecount()
, like in the README example code:This is somewhat redundant. Why do I have to say "bar" twice? ... instead, I should be able to write:
and get an optional which is nullopt if bar wasn't specified, and a boxed actual string if it was.
Bonus points if you support
std::experimental::optional
when C++14 is used.The text was updated successfully, but these errors were encountered: