|
Boost : |
Subject: Re: [boost] [review] string convert
From: Ivan Le Lann (ivan.lelann_at_[hidden])
Date: 2011-05-05 06:58:04
----- "Vladimir Batov" <vbatov_at_[hidden]> a écrit :
> > 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
IMHO, if following statement:
auto v = convert<int>from(str);
does not give an int, then I'd say that you should consider changing
the "convert" name. Call it "converter", "make_converter", etc.
> 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?
I dislike the idea that documentation should fix misleading names.
Regards,
Ivan
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk