Subject: Re: [boost] [lexical_cast] Fast conversion from boost::iterator_range<std::string::iterator>?
From: Jeroen Habraken (vexocide_at_[hidden])
Date: 2011-11-23 17:49:19
On 23 November 2011 17:55, Matthew Chambers <matt.chambers42_at_[hidden]> wrote:
> On Oct 13, 2011 Michel Morin wrote:
>> lexical_cast made optimizations for some types (such as `std::string`)
>> to achieve better performance. But, from my experience,
>> it seems that lexical_cast does not make any optimization for
>> Is there any plan to add optimization for such iterator ranges?
>> Â - `lexical_cast<int>(std::string(iter_rng.begin(), iter_rng.end()))`
>> is faster
>> Â Â than `lexical_cast<int>(iter_rng)`.
>> Â - Assuming it is safe to use `std::atoi`,
>> `std::atoi(&iter_rng.front())` is faster
>> Â Â than both of the above two methods.
>> (`iter_rng` is an instance of
> This post was on the boost users list but never got a reply. I figure it
> might be a better fit on the developer list. I too would like to see
> optimized conversions work on string ranges; what's the point in doing a
> fast conversion if you have to do a string copy first? :)
You might be interested in boost.coerce, a type-to-string and
string-to-type conversion library. The code can be found at
http://svn.boost.org/svn/boost/sandbox/coerce/ and an initial version
of the documentation at http://vexocide.org/coerce/.
It has the following customization points:
which would allow you to teach it about
If I find time I'll write a small example.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk