Boost logo

Boost Users :

From: Delfin Rojas (drojas_at_[hidden])
Date: 2005-06-03 12:30:41


Is this library freely available? It also sounds like a good addition to
boost itself...

-delfin

> -----Original Message-----
> From: boost-users-bounces_at_[hidden] [mailto:boost-users-
> bounces_at_[hidden]] On Behalf Of Martin
> Sent: Friday, June 03, 2005 4:22 AM
> To: boost-users_at_[hidden]
> Subject: [Boost-users] Re: lexical_cast
>
> I have a library which allows you to do all kind of conversions like
>
> to_string<string>(1234);
> to_string<wstring>(1234, &hex);
> to_string<fixed_string<10> >(10.25, make_tuple(&fixed, setprecision(1),
> setw
> (10)));
> to_string<string>(1234, locale::classic());
> to_string_classic<wstring>(1234); // same as above but with non-stream
> specializations for int (planning to add double)
>
> from_string<int>(str);
> from_string<double>(str, -5); // return -5 on error
> from_string<double>(str, &hex);
> from_string<int>(str, &noskipws, std::locale("German"), 0);
> from_string_classic<int>(str);
>
> If you have many conversions you can increase preformance by reusing the
> stream.
>
> basic_tofrom_string<string> conv(make_tuple(setprecision(2), &fixed),
> locale::classic());
>
> conv.to_string(1234, &hex);
> conv.to_char(1.234, setw(10)); // avoid copying result to std::string
> conv.from_string<double>(str, 0.0);
>
> All conversion routines uses a home-made streambuffer with optimizations
> to
> avoid copying and memory allocations (e.g. small string optimization &
> buffer
> reuse).
>
> Main benefit over lexical_cast is that you can control formatting & locale
> but
> performance is also much better due to less memory alllocations.
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net