Boost logo

Boost :

Subject: Re: [boost] [review] string convert
From: Scott McMurray (me22.ca+boost_at_[hidden])
Date: 2011-05-04 20:32:42


On Wed, May 4, 2011 at 16:03, Gordon Woodhull <gordon_at_[hidden]> wrote:
>
> On May 4, 2011, at 3:03 PM, Scott McMurray wrote:
>> The scary implicit conversions might even make some sense when there's
>> no destination type:
>>    int i = convert(x);
>
> Please read the posts (esp Thomas Heller's and Christopher Jefferson's) about how implicit conversions break template functions and auto.  They're more than just scary.
>

I completely agree they're not appropriate in the normal path.

But there's a difference between having explicit conversions from
    convert<int>::from(x)
and from
    convert(x)

Because in the former there's enough information to determine the
result type. In the latter there isn't, so expecting it to return
anything other than a proxy is illogical.

The idea was simply to have a way to prevent the need for repeating
the type in both 03 and 0x:
    int i = convert(x);
    auto i = convert(x).to<int>();

"i" being a proxy in
    auto i = convert<int>::from(x);
is weird, I agree.

"i" being a proxy in
    auto i = convert(x);
is perfectly reasonably, since convert(x) visibly can't possibly have
figured out the right type.

But sure, the problem with template functions is perhaps a deal-breaker.

~ Scott


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk