@@ -963,8 +963,8 @@ operator<<(std::basic_ostream<CharT, Traits>& os, const year_month_weekday_last&
963963inline namespace literals
964964{
965965
966- CONSTCD11 date::day operator " " _d(unsigned long long d) NOEXCEPT;
967- CONSTCD11 date::year operator " " _y(unsigned long long y) NOEXCEPT;
966+ CONSTCD11 date::day operator " " _d(unsigned long long d) NOEXCEPT;
967+ CONSTCD11 date::year operator " " _y(unsigned long long y) NOEXCEPT;
968968
969969} // inline namespace literals
970970#endif // !defined(_MSC_VER) || (_MSC_VER >= 1900)
@@ -1972,15 +1972,15 @@ inline namespace literals
19721972CONSTCD11
19731973inline
19741974date::day
1975- operator " " _d(unsigned long long d) NOEXCEPT
1975+ operator " " _d(unsigned long long d) NOEXCEPT
19761976{
19771977 return date::day{static_cast <unsigned >(d)};
19781978}
19791979
19801980CONSTCD11
19811981inline
19821982date::year
1983- operator " " _y(unsigned long long y) NOEXCEPT
1983+ operator " " _y(unsigned long long y) NOEXCEPT
19841984{
19851985 return date::year (static_cast <int >(y));
19861986}
@@ -6784,7 +6784,7 @@ from_stream(std::basic_istream<CharT, Traits>& is, const CharT* fmt,
67846784 checked_set (m, static_cast <int >(i % 12 + 1 ), not_a_month, is);
67856785 ws (is);
67866786 int td = not_a_day;
6787- read (is, rs {td, 1 , 2 });
6787+ read (is, ru {td, 1 , 2 });
67886788 checked_set (d, td, not_a_day, is);
67896789 ws (is);
67906790 using dfs = detail::decimal_format_seconds<Duration>;
@@ -6800,7 +6800,9 @@ from_stream(std::basic_istream<CharT, Traits>& is, const CharT* fmt,
68006800 not_a_second, is);
68016801 ws (is);
68026802 int tY = not_a_year;
6803- read (is, rs{tY, 1 , 4u });
6803+ // No need for `rs` here, negative years can't parse
6804+ // with "%c" since `width` is hardcoded to 4
6805+ read (is, ru{tY, 1 , 4u });
68046806 checked_set (Y, tY, not_a_year, is);
68056807#endif
68066808 }
@@ -6834,7 +6836,7 @@ from_stream(std::basic_istream<CharT, Traits>& is, const CharT* fmt,
68346836 int tm = not_a_month;
68356837 int td = not_a_day;
68366838 read (is, ru{tm, 1 , 2 }, CharT{' /' }, ru{td, 1 , 2 }, CharT{' /' },
6837- rs {ty, 1 , 2 });
6839+ ru {ty, 1 , 2 });
68386840 checked_set (y, ty, not_a_2digit_year, is);
68396841 checked_set (m, tm, not_a_month, is);
68406842 checked_set (d, td, not_a_day, is);
@@ -6930,7 +6932,7 @@ from_stream(std::basic_istream<CharT, Traits>& is, const CharT* fmt,
69306932 int ty = not_a_2digit_year;
69316933 read (is, ru{tn, 1 , 2 }, CharT{' \0 ' }, CharT{' /' }, CharT{' \0 ' },
69326934 ru{td, 1 , 2 }, CharT{' \0 ' }, CharT{' /' }, CharT{' \0 ' },
6933- rs {ty, 1 , 2 });
6935+ ru {ty, 1 , 2 });
69346936 checked_set (y, ty, not_a_2digit_year, is);
69356937 checked_set (m, tn, not_a_month, is);
69366938 checked_set (d, td, not_a_day, is);
@@ -6978,7 +6980,7 @@ from_stream(std::basic_istream<CharT, Traits>& is, const CharT* fmt,
69786980#endif
69796981 {
69806982 int td = not_a_day;
6981- read (is, rs {td, 1 , width == -1 ? 2u : static_cast <unsigned >(width)});
6983+ read (is, ru {td, 1 , width == -1 ? 2u : static_cast <unsigned >(width)});
69826984 checked_set (d, td, not_a_day, is);
69836985 }
69846986#if !ONLY_C_LOCALE
@@ -7042,7 +7044,7 @@ from_stream(std::basic_istream<CharT, Traits>& is, const CharT* fmt,
70427044 {
70437045 int tI = not_a_hour_12_value;
70447046 // reads in an hour into I, but most be in [1, 12]
7045- read (is, rs {tI, 1 , width == -1 ? 2u : static_cast <unsigned >(width)});
7047+ read (is, ru {tI, 1 , width == -1 ? 2u : static_cast <unsigned >(width)});
70467048 if (!(1 <= tI && tI <= 12 ))
70477049 is.setstate (ios::failbit);
70487050 checked_set (I, tI, not_a_hour_12_value, is);
@@ -7116,7 +7118,7 @@ from_stream(std::basic_istream<CharT, Traits>& is, const CharT* fmt,
71167118#endif
71177119 {
71187120 int tn = not_a_month;
7119- read (is, rs {tn, 1 , width == -1 ? 2u : static_cast <unsigned >(width)});
7121+ read (is, ru {tn, 1 , width == -1 ? 2u : static_cast <unsigned >(width)});
71207122 checked_set (m, tn, not_a_month, is);
71217123 }
71227124#if !ONLY_C_LOCALE
@@ -7536,7 +7538,7 @@ from_stream(std::basic_istream<CharT, Traits>& is, const CharT* fmt,
75367538 }
75377539 if (modified == CharT{})
75387540 {
7539- read (is, rs {tH, 2 , 2 });
7541+ read (is, ru {tH, 2 , 2 });
75407542 if (!is.fail ())
75417543 toff = hours{std::abs (tH)};
75427544 if (is.good ())
@@ -7556,7 +7558,7 @@ from_stream(std::basic_istream<CharT, Traits>& is, const CharT* fmt,
75567558 }
75577559 else
75587560 {
7559- read (is, rs {tH, 1 , 2 });
7561+ read (is, ru {tH, 1 , 2 });
75607562 if (!is.fail ())
75617563 toff = hours{std::abs (tH)};
75627564 if (is.good ())
@@ -7575,7 +7577,7 @@ from_stream(std::basic_istream<CharT, Traits>& is, const CharT* fmt,
75757577 }
75767578 }
75777579 }
7578- if (neg)
7580+ if (neg && !is. fail () )
75797581 toff = -toff;
75807582 checked_set (temp_offset, toff, not_a_offset, is);
75817583 command = nullptr ;
@@ -8117,6 +8119,8 @@ struct parse_manip
81178119#endif // HAS_STRING_VIEW
81188120};
81198121
8122+ #ifdef _MSC_VER
8123+
81208124template <class Parsable , class CharT , class Traits , class Alloc >
81218125std::basic_istream<CharT, Traits>&
81228126operator >>(std::basic_istream<CharT, Traits>& is,
@@ -8220,6 +8224,113 @@ parse(const CharT* format, Parsable& tp,
82208224 return {format, tp, &abbrev, &offset};
82218225}
82228226
8227+ #else // !defined _MSC_VER
8228+
8229+ template <class Parsable , class CharT , class Traits , class Alloc >
8230+ std::basic_istream<CharT, Traits>&
8231+ operator >>(std::basic_istream<CharT, Traits>& is,
8232+ const parse_manip<Parsable, CharT, Traits, Alloc>& x)
8233+ {
8234+ return from_stream (is, x.format_ .c_str (), x.tp_ , x.abbrev_ , x.offset_ );
8235+ }
8236+
8237+ template <class Parsable , class CharT , class Traits , class Alloc >
8238+ inline
8239+ auto
8240+ parse (const std::basic_string<CharT, Traits, Alloc>& format, Parsable& tp)
8241+ -> decltype (from_stream (std::declval<std::basic_istream<CharT, Traits>&>(),
8242+ format.c_str (), tp),
8243+ parse_manip<Parsable, CharT, Traits, Alloc>{format, tp})
8244+ {
8245+ return {format, tp};
8246+ }
8247+
8248+ template <class Parsable , class CharT , class Traits , class Alloc >
8249+ inline
8250+ auto
8251+ parse (const std::basic_string<CharT, Traits, Alloc>& format, Parsable& tp,
8252+ std::basic_string<CharT, Traits, Alloc>& abbrev)
8253+ -> decltype (from_stream (std::declval<std::basic_istream<CharT, Traits>&>(),
8254+ format.c_str (), tp, &abbrev),
8255+ parse_manip<Parsable, CharT, Traits, Alloc>{format, tp, &abbrev})
8256+ {
8257+ return {format, tp, &abbrev};
8258+ }
8259+
8260+ template <class Parsable , class CharT , class Traits , class Alloc >
8261+ inline
8262+ auto
8263+ parse (const std::basic_string<CharT, Traits, Alloc>& format, Parsable& tp,
8264+ std::chrono::minutes& offset)
8265+ -> decltype (from_stream (std::declval<std::basic_istream<CharT, Traits>&>(),
8266+ format.c_str (), tp,
8267+ std::declval<std::basic_string<CharT, Traits, Alloc>*>(),
8268+ &offset),
8269+ parse_manip<Parsable, CharT, Traits, Alloc>{format, tp, nullptr , &offset})
8270+ {
8271+ return {format, tp, nullptr , &offset};
8272+ }
8273+
8274+ template <class Parsable , class CharT , class Traits , class Alloc >
8275+ inline
8276+ auto
8277+ parse (const std::basic_string<CharT, Traits, Alloc>& format, Parsable& tp,
8278+ std::basic_string<CharT, Traits, Alloc>& abbrev, std::chrono::minutes& offset)
8279+ -> decltype (from_stream (std::declval<std::basic_istream<CharT, Traits>&>(),
8280+ format.c_str (), tp, &abbrev, &offset),
8281+ parse_manip<Parsable, CharT, Traits, Alloc>{format, tp, &abbrev, &offset})
8282+ {
8283+ return {format, tp, &abbrev, &offset};
8284+ }
8285+
8286+ // const CharT* formats
8287+
8288+ template <class Parsable , class CharT >
8289+ inline
8290+ auto
8291+ parse (const CharT* format, Parsable& tp)
8292+ -> decltype (from_stream (std::declval<std::basic_istream<CharT>&>(), format, tp),
8293+ parse_manip<Parsable, CharT>{format, tp})
8294+ {
8295+ return {format, tp};
8296+ }
8297+
8298+ template <class Parsable , class CharT , class Traits , class Alloc >
8299+ inline
8300+ auto
8301+ parse (const CharT* format, Parsable& tp, std::basic_string<CharT, Traits, Alloc>& abbrev)
8302+ -> decltype (from_stream (std::declval<std::basic_istream<CharT, Traits>&>(), format,
8303+ tp, &abbrev),
8304+ parse_manip<Parsable, CharT, Traits, Alloc>{format, tp, &abbrev})
8305+ {
8306+ return {format, tp, &abbrev};
8307+ }
8308+
8309+ template <class Parsable , class CharT >
8310+ inline
8311+ auto
8312+ parse (const CharT* format, Parsable& tp, std::chrono::minutes& offset)
8313+ -> decltype (from_stream (std::declval<std::basic_istream<CharT>&>(), format,
8314+ tp, std::declval<std::basic_string<CharT>*>(), &offset),
8315+ parse_manip<Parsable, CharT>{format, tp, nullptr , &offset})
8316+ {
8317+ return {format, tp, nullptr , &offset};
8318+ }
8319+
8320+ template <class Parsable , class CharT , class Traits , class Alloc >
8321+ inline
8322+ auto
8323+ parse (const CharT* format, Parsable& tp,
8324+ std::basic_string<CharT, Traits, Alloc>& abbrev, std::chrono::minutes& offset)
8325+ -> decltype (from_stream (std::declval<std::basic_istream<CharT, Traits>&>(), format,
8326+ tp, &abbrev, &offset),
8327+ parse_manip<Parsable, CharT, Traits, Alloc>{format, tp, &abbrev, &offset})
8328+ {
8329+ return {format, tp, &abbrev, &offset};
8330+ }
8331+
8332+ #endif // !defined _MSC_VER
8333+
82238334// duration streaming
82248335
82258336template <class CharT , class Traits , class Rep , class Period >
0 commit comments