Subject: Re: [boost] [Review] Boost.Convert library, last day
From: Christopher Jefferson (chris_at_[hidden])
Date: 2011-05-03 11:22:59
On 3 May 2011, at 13:19, Thomas Heller wrote:
> On Tue, May 3, 2011 at 12:41 PM, Vladimir Batov <vbatov_at_[hidden]> wrote:
>>> Hartmut Kaiser <hartmut.kaiser <at> gmail.com> writes:
>>> From reading the docs I came away puzzled. It was highly confusing to me to
>>> have the convert::from<> return different things in different contexts.
>> I was under impression that from the user perspective convert::from returns
>> either the converted value or convert::result in all contexts. If users "really
>> just want to do the conversion without spending much time reading the docs",
>> then they'll use
>> int i = convert<int>::from(string)
>> as described in "Getting Started" without even knowing there is convert::result.
>> Hardly puzzling and confusing.
>>> As Thomas Heller pointed out, the existence of several default conversion
>>> paths for the result type will (with high probability) create havoc for
>>> users who really just want to do the conversion without spending much time
>>> reading the docs.
>> Secondly, I am not sure about "existence of several default conversion paths for
>> the result type". Again, the only types convert::from result is converted to are
>> the Target type and the convert::result type. Both types are for different uses
>> and are described in the docs. As for Thomas Heller's doomsday predictions, then
>> it must be so if he says so. Or may be not. I do not see it that way anyway.
> Sorry, this statement is wrong.
> At the very least convert<T>::from returns exactly one thing which is
> this converter thingy,
> which is implicitly converted to either convert<T>::result or T. And
> yes, this means that
> the result is different based on the LHS of from, which is out of your
> control and doomed to fail.
> I wonder how much codes breaks by having this.
> Consider the following example:
> #include <boost/convert.hpp>
> #include <string>
> template <typename Char, typename Allocator>
> void f(std::basic_string<Char, Allocator> string)
> int main()
> Which is not working because of this design flaw I constantly keep
> mocking about.
Out of interest, what would:
auto str = boost::convert<std::string>::from(123);
Do? If boost::convert stores by pointer/reference, it would be quite dangerous.
I think making libraries 'auto safe' is a good idea, I expect to see auto usage shoot up very quickly, and libraries should do their best to work well with auto.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk