Boost logo

Boost :

Subject: Re: [boost] [review] string convert
From: Matthew Chambers (matt.chambers42_at_[hidden])
Date: 2011-05-03 16:13:27

On 5/3/2011 1:26 PM, Stewart, Robert wrote:
> Unfortunately, I realized that wouldn't work well for string literals, for example.

I had no idea that dynamic_cast behavior differed between reference and pointers types. I'm no C++
guru but I'm no amateur either, so I don't think that's a good model to follow even if it did work
for string literals.

C# has Parse (returns value and throws if parse fails) and TryParse (returns bool if parse succeeds
and returns parsed value in a variable passed by reference) for each primitive numeric type. It's
very intuitive but not very generic. So I can definitely see a convert_to and try_convert_to but I'd
rather simply have a no-throw version of lexical_cast: 'try_lexical_cast'. The default
construct-ability use case is really a hassle though. I think it needs to be discussed how important
it is for simple lexical conversion to support non-default-constructable target types. The "simple
things should be simple" principle seems very applicable here.


Boost list run by bdawes at, gregod at, cpdaniel at, john at