Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions include/argparse.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -964,6 +964,16 @@ namespace argparse

virtual auto get_name_for_error() const -> std::string = 0;

static auto is_negative_number(std::string const & token) -> bool
{
auto num = double();
if (from_string(token, num))
{
return true;
}
return false;
}

private:
ArgumentCommonImpl m_impl;
};
Expand Down Expand Up @@ -1034,10 +1044,7 @@ namespace argparse
{
return true;
}
auto iss = std::istringstream(token.m_token);
auto num = double();
iss >> num;
if (!iss.fail() && (iss.eof() || iss.peek() == std::istringstream::traits_type::eof()))
if (is_negative_number(token.m_token))
{
return true;
}
Expand Down Expand Up @@ -1412,10 +1419,7 @@ namespace argparse
{
return true;
}
auto iss = std::istringstream(token.m_token);
auto num = double();
iss >> num;
if (!iss.fail() && (iss.eof() || iss.peek() == std::istringstream::traits_type::eof()))
if (is_negative_number(token.m_token))
{
return true;
}
Expand Down