The current API for extracting the scanned result is very cumbersome (IMO).
Sometimes it is better to return a fallback value when scan fails.
...
auto number = scn::input<int>("{}").value_or(42);
...
The current way of achieving this is unnecessarily long.
...
int number; // Have an uninitialized variable
if (auto result = scn::input<int>("{}"); result) {
number = result->value();
else {
number = 42;
}
...
or
...
int number = scn::input<int>("{}").value().value(); // Could throw and no fallback value
...
Having a scn::scan_result inside a std::expected can be somewhat inconvenient. Maybe having a single result type would be better?
The current API for extracting the scanned result is very cumbersome (IMO).
Sometimes it is better to return a fallback value when scan fails.
The current way of achieving this is unnecessarily long.
or
Having a
scn::scan_resultinside astd::expectedcan be somewhat inconvenient. Maybe having a single result type would be better?