@@ -2003,12 +2003,16 @@ Target parse(Target, Source)(ref Source s)
20032003 enum bool sign = 0 ;
20042004
20052005 enum char maxLastDigit = Target.min < 0 ? 7 : 5 ;
2006- Unqual ! ( typeof (s.front)) c;
2006+ uint c;
20072007
20082008 if (s.empty)
20092009 goto Lerr;
20102010
2011- c = s.front;
2011+ static if (isAutodecodableString! Source)
2012+ c = s[0 ];
2013+ else
2014+ c = s.front;
2015+
20122016 static if (Target.min < 0 )
20132017 {
20142018 switch (c)
@@ -2017,10 +2021,19 @@ Target parse(Target, Source)(ref Source s)
20172021 sign = true ;
20182022 goto case ' +' ;
20192023 case ' +' :
2020- s.popFront();
2024+ static if (isAutodecodableString! Source)
2025+ s = s[1 .. $];
2026+ else
2027+ s.popFront();
2028+
20212029 if (s.empty)
20222030 goto Lerr;
2023- c = s.front;
2031+
2032+ static if (isAutodecodableString! Source)
2033+ c = s[0 ];
2034+ else
2035+ c = s.front;
2036+
20242037 break ;
20252038
20262039 default :
@@ -2031,10 +2044,19 @@ Target parse(Target, Source)(ref Source s)
20312044 if (c <= 9 )
20322045 {
20332046 Target v = cast (Target)c;
2034- s.popFront();
2047+
2048+ static if (isAutodecodableString! Source)
2049+ s = s[1 .. $];
2050+ else
2051+ s.popFront();
2052+
20352053 while (! s.empty)
20362054 {
2037- c = cast (typeof (c)) (s.front - ' 0' );
2055+ static if (isAutodecodableString! Source)
2056+ c = cast (typeof (c)) (s[0 ] - ' 0' );
2057+ else
2058+ c = cast (typeof (c)) (s.front - ' 0' );
2059+
20382060 if (c > 9 )
20392061 break ;
20402062
@@ -2044,7 +2066,11 @@ Target parse(Target, Source)(ref Source s)
20442066 // Note: `v` can become negative here in case of parsing
20452067 // the most negative value:
20462068 v = cast (Target) (v * 10 + c);
2047- s.popFront();
2069+
2070+ static if (isAutodecodableString! Source)
2071+ s = s[1 .. $];
2072+ else
2073+ s.popFront();
20482074 }
20492075 else
20502076 throw new ConvOverflowException(" Overflow in integral conversion" );
0 commit comments