This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Patch] First step towards fast parsing of float types


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 ()));
}



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]