Boost logo

Boost :

Subject: Re: [boost] Formal Review Request: Boost.Convert
From: Vladimir.Batov_at_[hidden]
Date: 2009-02-19 17:05:27

I've implemented the functionality as I described (convert as a class) and
uploaded it as v0.21.

I feel it is a considerable step forward in many respects as now it is
more of a conversion 'framework' as users can create their specific
specializations of boost::convert for their specific needs (as I did with

At the same time it feels reconciliatory as fighting over names could be
put to rest (I hope) as we or the users might write simple and generic
wrappers to boost::convert. In particular, I added boost::convert_to and
boost::convert_from. It's just a suggestion. We might decide to keep them
or remove or rename them. I am not fussy about it. So, the deployment loos
as follows:

// Explicitly specified 'from' and 'to' types. My personal preference
int i = boost::convert<string, int>(str, -1);
string s = boost::convert<int, string>(-1, "conversion failed");

// Deduced 'from' type.
int i = boost::convert_to<int>(str);
string s = boost::convert_to<string>(-1);

// Both types are deduced.
int i = boost::convert_from(str, -1);
string s = boost::convert_from(-1, "conversion failed");

Robert suggested renaming 'convert' to 'conversion' but I am not warming
up to that (yet, you might have noticed I am slow) as I essentially see
'convert' as a functor, i.e. encapsulating as an action, i.e. a verb is
more appropriate. For that reason the code itself looks readable (to me)
as "boost::convert<int, string>" reads as 'convert int to string".


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