Boost logo

Boost :

Subject: Re: [boost] [review] Convert library
From: feverzsj (feverzsj_at_[hidden])
Date: 2014-05-25 14:04:21

I agree the converter concept is a step forward. And it's also a good idea to
support both exception and defualt value on failure. The functor interface
is useful, too.
But as other reviewer mentioned, the convert interface seems less intuitive
and lack a default convenient interface.

Personally, I'd prefer something like:
// cast like interface
T t = conv_to<T>(from, cnv); // compare to T t =
convert<T>::from(from, cnv).value();
T t = conv_to<T>(from, default_v, cnv); // compare to T t =
convert<T>::from(from, cnv).value_or(default_v);

// plain interface
bool re = convert(from, to, cnv);

// functor interface
std::transfrom(first, last, out, convert<T>(from, cnv)));
std::transfrom(first, last, out, convert<T>(from, default_v, cnv)));

** with defualt interface version, "cnv" will be ignored

Using only two names, we can get something simple and intuitive. The
implemention can be also effectively simplfied.


View this message in context:
Sent from the Boost - Dev mailing list archive at

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