forked from HowardHinnant/date
Allow read_unsigned to read 0 digits
* Will allow reading "optional" integers.
This commit is contained in:
5
date.h
5
date.h
@@ -5297,7 +5297,7 @@ read_signed(std::basic_istream<CharT, Traits>& is, unsigned m = 1, unsigned M =
|
|||||||
{
|
{
|
||||||
if (c == '-' || c == '+')
|
if (c == '-' || c == '+')
|
||||||
(void)is.get();
|
(void)is.get();
|
||||||
auto x = static_cast<int>(read_unsigned(is, m, M));
|
auto x = static_cast<int>(read_unsigned(is, std::max(m, 1u), M));
|
||||||
if (!is.fail())
|
if (!is.fail())
|
||||||
{
|
{
|
||||||
if (c == '-')
|
if (c == '-')
|
||||||
@@ -5306,7 +5306,8 @@ read_signed(std::basic_istream<CharT, Traits>& is, unsigned m = 1, unsigned M =
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
is.setstate(std::ios::failbit);
|
if (m > 0)
|
||||||
|
is.setstate(std::ios::failbit);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user