Boost logo

Boost :

Subject: Re: [boost] [lexical cast] Performance improvements
From: Christopher Jefferson (chris_at_[hidden])
Date: 2011-03-20 09:32:11


On 19 Mar 2011, at 20:44, Antony Polukhin wrote:

> Working with Boost Lexical Cast library found that some casts are
> working really slow.
> For example, cast from short to int is done via cast from short to char[],
> and cast from char[] to int.
> Cast from char* to string is done via string() constructor call and string`s
> append function call (instead of string constructor call with char array as a
> parameter).
>
> So I wrote patch to Boost Lexical Cast library, that returns Target directly
> constructed from Source in cases, when:
> 1) Source and Target are arithmetics (and not char or wchar_t), and
> all values of
> Source are in range of Target
> 2) Source and Target are both char or both wchar_t
> 3) Source is array of CharT and Target is std::basic_string<CharT, ...>
> 4) Source and Target are std::basic_string with same template parameters

Just one quick question, does your code have the same behaviour as the existing Lexical Cast when casting out of bounds (int -> unsigned int, int -> short, unsigned int -> int)?

Chris


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk