aboutsummaryrefslogtreecommitdiff
path: root/args.hxx
diff options
context:
space:
mode:
authorPavel Belikov <pavel.fuchs.belikov@gmail.com>2019-06-25 21:43:00 +0300
committerPavel Belikov <pavel.fuchs.belikov@gmail.com>2019-06-25 21:43:00 +0300
commit77961bf9a4886bddc3ab567aeb1093943ff816ca (patch)
tree544ed67d72e5849a65848bf20e3771c4cd0ae27d /args.hxx
parentMerge pull request #73 from zhihaoy/cmake-targets (diff)
downloadargs.hxx-77961bf9a4886bddc3ab567aeb1093943ff816ca.tar.xz
Fixes #75 : Check istringstream state in ValueParser
Diffstat (limited to 'args.hxx')
-rw-r--r--args.hxx9
1 files changed, 7 insertions, 2 deletions
diff --git a/args.hxx b/args.hxx
index 09c1919..563169c 100644
--- a/args.hxx
+++ b/args.hxx
@@ -3256,9 +3256,14 @@ namespace args
operator ()(const std::string &name, const std::string &value, T &destination)
{
std::istringstream ss(value);
- ss >> destination >> std::ws;
+ bool failed = !(ss >> destination);
- if (ss.rdbuf()->in_avail() > 0)
+ if (!failed)
+ {
+ ss >> std::ws;
+ }
+
+ if (ss.rdbuf()->in_avail() > 0 || failed)
{
#ifdef ARGS_NOEXCEPT
(void)name;