Reset command, width and modified for %n and %t in from_stream.

This commit is contained in:
Howard Hinnant 2017-05-04 21:03:48 -04:00
parent f57432d7b4
commit cf0481b9af
2 changed files with 16 additions and 0 deletions

3
date.h
View File

@ -5805,6 +5805,9 @@ from_stream(std::basic_istream<CharT, Traits>& is, const CharT* fmt,
for (++fmt; *fmt == 'n' || *fmt == 't'; ++fmt) for (++fmt; *fmt == 'n' || *fmt == 't'; ++fmt)
; ;
--fmt; --fmt;
command = nullptr;
width = -1;
modified = CharT{};
} }
else else
read(is, *fmt); read(is, *fmt);

View File

@ -728,6 +728,18 @@ test_trailing_Z()
assert(input.eof()); assert(input.eof());
} }
void
test_leading_ws()
{
using namespace std;
using namespace date;
istringstream in{"05/04/17 5/4/17"};
year_month_day d1, d2;
in >> parse("%D", d1) >> parse("%n%D", d2);
assert(d1 == may/4/2017);
assert(d2 == may/4/2017);
}
int int
main() main()
{ {
@ -756,4 +768,5 @@ main()
test_z(); test_z();
test_Z(); test_Z();
test_trailing_Z(); test_trailing_Z();
test_leading_ws();
} }