Boost logo

Boost :

Subject: Re: [boost] [review] string convert
From: Matthew Chambers (matt.chambers42_at_[hidden])
Date: 2011-05-04 14:37:01

On 5/4/2011 1:18 PM, Stewart, Robert wrote:
> try_convert(s, i) doesn't tell me whether s is being converted to i's type or i to s's type.
I don't think this is a problem in practice. C#'s TryParse has the same semantics, albeit you're
forced to use the out keyword on the second argument, so perhaps that's not a fair comparison.

> convert_cast(s, 17) has the same problem and breaks with the new-style cast pattern.
What is the breaking aspect?

> The target type should be required in all cases, I suspect, to make things clearer:
> try_convert_to<int>(s, i) clearly indicates that int is the target type.
> convert_cast<int>(s, 17) is likewise better.
Yes, but thanks to type inference users are free to write try_convert_to(s, i) instead and that's
even worse than try_convert(s, i). :)

Did we just rediscover Vladimir's reasoning for the ::from interface? If so, I think the cure is
worse than the disease.


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