This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: [Patch] First step towards fast parsing of float types
- From: Martin Sebor <sebor at roguewave dot com>
- To: libstdc++ <libstdc++ at gcc dot gnu dot org>
- Date: Thu, 18 Dec 2003 11:22:22 -0700
- Subject: Re: [Patch] First step towards fast parsing of float types
- References: <3FE1C11C.7040502@suse.de>
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 ()));
}