Boost logo

Boost :

Subject: Re: [boost] Boost.Conversion - pre review request
From: Gordon Woodhull (gordon_at_[hidden])
Date: 2011-07-09 11:19:33

On Jul 9, 2011, at 10:20 AM, Vicente Botet <vicente.botet_at_[hidden]> wrote:

> Jeroen Habraken wrote:
>> Colour me curious, but what's the advantage of wrapping boost.coerce
>> in boost.conversion? We're trying to create a sensible API for
>> boost.coerce (which, as we've seen, is quite a challenge for a
>> conversion library) and I personally do not see the benefit of it
>> being wrapped with a different API in a different library.

If you know that one of your types is string, then there would be no reason to use something more generic than Coerce or lexical_cast.

However in generic programming it sometimes comes up that you need to convert from type X to type Y and you don't care whether either is a string.

> The scope of Boost.Conversion is not to define specific conversions but
> allow to put all the basic type-to-type conversion using a generic
> interface. If Boost.Coerce provide an string to type efficient conversion
> Boost.Conversion can provide a specialization for string to types conversion
> that will delegate to Boost.Coerce. At the end std::string is a type as
> others.

Another interesting example of using Conversion along with Coerce is e.g. convert pair<string, string> to pair<int, int>

If formatting options are required, I don't think there is any good way to convert between pair<int, string> and pair<string, int>. But that's got to be pretty rare.

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