Boost logo

Boost :

Subject: Re: [boost] Formal Review Request: Boost.Convert
From: Vladimir.Batov_at_[hidden]
Date: 2009-02-23 14:38:55

Stewart, Robert wrote...

> I assume that's a reference to me. My suggestion of "conversion" was as
a namespace name.
> Were you referring to my suggestion of using "converter" for the
function object and "convert"
> for the function template that would deduce template parameters?

Yes, I was referring to that latter suggestion of yours:

>> namespace boost
>> {
>> ...class convert;

> s/convert/converter/
> template <class TypeOut, class TypeIn>
> TypeOut const
> convert(TypeIn _input, TypeOut const & _default)
> {
> return converter<TypeIn,TypeOut>(_input, _default);
> }

I've essentially implemented function wrappers as you suggested. Only I
called them convert_to() and convert_from() that I am hoping many people
will be happy with (remembering string_to/from et al) as the names could
not be any clearer:

int i = convert_to<int>(str);
int i = convert_from(str, -1);
int i = convert_from<string, double>(str, -1);

That allowed me to keep the function object as "convert" and, say, apply
it to algorithms as

        convert<string, int>(string(), -1) >> std::hex);

which is kinda nice as well. Do you agree?


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