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

Simplify parsing numeric arguments with .scan #65

Merged
merged 3 commits into from
Nov 26, 2019
Merged

Conversation

lichray
Copy link
Contributor

@lichray lichray commented Nov 26, 2019

Limitations due to portability :

  1. This patch uses from_chars for parsing integer numbers. To do so, I bumped required GCC version to 8.x and required Clang/libc++ version to 7.x.
  2. This patch emulates from_chars behavior for parsing floating-point numbers with strtod, but this function is locale-aware.
  3. The emulation does not use strict grammar to distinguish fixed and scientific format. As a result, NAN(char_sequence) (signal NaN, but should be parsed as quiet NaN) may fail to parsed.

Caveats:

  1. There is no base == 0 case for from_chars; integer format detection for 'i' shape is done by hand.
  2. Hexfloat is not considered possibly negative as positional argument, so negative hexfloat currently is not a valid input.
  3. + sign is not allowed, but this is a result of sticking with from_chars's grammar.
  4. We throw range_error for ERANGE and std::errc::result_out_of_range, unlike stoi and stod which throw out_of_range. Our choice is correct here.

fixes: #63

@p-ranav p-ranav merged commit 4277e68 into p-ranav:master Nov 26, 2019
@lichray lichray deleted the scan branch December 2, 2019 08:21
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

Successfully merging this pull request may close these issues.

Simplify parsing numeric arguments with predefined actions
2 participants