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

Handle "inf", "-inf" and "nan" for double and float types #314

Open
darcamo opened this issue Oct 29, 2021 · 0 comments
Open

Handle "inf", "-inf" and "nan" for double and float types #314

darcamo opened this issue Oct 29, 2021 · 0 comments

Comments

@darcamo
Copy link

darcamo commented Oct 29, 2021

Currently when parsing values as double or float, cxxopts uses the fallback parser using stringstream. However, using input streams does not support a representation for infinity and NaN (see this stack overflow question) .

It seems that all that is needed to support passing "infinity" and similar values that can be properly parsed is to add two specialization of parse_value, one for double, that uses std::stod, and one for float, that uses std::stof.

Another specialization for long double could also be added that uses std::stold.

Note that std::stod, std::stof and std::stold were introduced in C++11.

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