[Patch] First step towards fast parsing of float types

Martin Sebor sebor@roguewave.com
Thu Dec 18 18:23:00 GMT 2003


Paolo Carlini wrote:

> Hi,
> 
> this tiny step only clarifies a bit the logic in some (corner)
> cases and adds missing testcases. Basically, we were accepting
> thousands separators and decimal point also *after* 'e'/'E'.

FWIW, your (i.e., libstdc++) handling of thousands_sep and
decimal_point is off in one other respect as well. Stage 2
specifies that these special characters be processed _prior_
to any digits. Libstdc++ process them _after_. A super-
pedantic test case is below ;-)

Best
Martin


#include <locale>
#include <sstream>

int main ()
{
     struct Punct: std::numpunct<char> {
         std::string do_grouping () const { return "\1"; }
         char do_thousands_sep () const { return '2'; }
         char do_decimal_point () const { return '4'; }
     };

     std::stringstream strm ("1234");

     strm.imbue (std::locale (strm.getloc (), (std::numpunct<char>*)new 
Punct));

     double d = 0;

     strm >> d;

     return !(13.0 == d && (std::ios::eofbit == strm.rdstate ()));
}




More information about the Libstdc++ mailing list