Boost logo

Boost :

Subject: Re: [boost] [review] string convert
From: Vladimir Batov (vbatov_at_[hidden])
Date: 2011-05-05 06:38:30


> Scott McMurray <me22.ca+boost <at> gmail.com> writes:
>
>> Gordon Woodhull <gordon <at> woodhull.com> wrote:
>>
>> 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.

I do not want to re-start that sub-thread. Still, I feel that that line of
'convert' releasing the Satan with implicit conversions to the Target type and
to convert<Target>::result has been blown out of all proportions.

The implicit conversion to the Target type was essentially a convenience (which
we in our project deploy all the time). We could remove it as it could be
retrieved with value(). Does the only remaining implicit conversion to such
specific type convert<>::result still look scary?

In reality, all that was needed to avoid the "break template functions and auto"
scenario was

    template<class T> foo(T const&);
    int v = convert<int>from(str);
    auto v1 = convert<int>from(str).value();
    foo(v); // correct template resolution
or
    template<class T> foo(T const&);
    foo(convert<int>from(str).value); // correct template resolution

Was it too much to ask? How many libraries can claim to support an attitude like
-- I do not want to read the documentation, I want to call those functions as I
see fit and I expect them to work correctly?

V.


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