|
Boost : |
Subject: Re: [boost] construe_cast, call for interest and feedback
From: Jeroen Habraken (vexocide_at_[hidden])
Date: 2010-10-11 08:13:06
On 11 October 2010 10:34, Richard Hazlewood <boost_at_hazlewoods.eu> wrote:
> Jeroen Habraken <vexocide <at> gmail.com> writes:
>
>>
>> On 7 October 2010 22:59, Matthew Herrmann <matthew.herrmann <at> zomojo.com>
> wrote:
>> > Also are you adding array of char as an input specialization? I like the
> way it avoids the strlen for const
>> char literals on the rhs.
>>
>> Yes I am, the specific specializations can be found at
>>
> http://github.com/VeXocide/construe_cast/blob/master/boost/construe/iterable.hp
> p
>> lines 120 to 165
>
> The fixed-size array-of-char specializations seem like a good idea, but (the
> user) can fall into the same trap as the (v3) filesystem constructor does
> (trac #4640), e.g.:
>
> Â char buffer[100];
> Â strcpy(buffer, "100");
> Â construe_cast<int>(buffer);
>
> Depending on how the size (100) is taken into account, this may or may not be
> an issue.
>
Since the string is null-terminated this is not a problem. If for
instance you cast "123\0456" to an int it will succeed and return 123,
as far as I'm aware this behaviour is similar to lexical_cast.
Jeroen
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk