Boost logo

Boost :

Subject: Re: [boost] [convert] are you mixing default_value and error_value?
From: Gottlob Frege (gottlobfrege_at_[hidden])
Date: 2009-07-09 09:31:14


On Thursday, July 9, 2009, Vicente Botet Escriba
<vicente.botet_at_[hidden]> wrote:
>
>
>
> Vladimir Batov wrote:
>>
>>> From: "Vicente Botet Escriba" <vicente.botet_at_[hidden]>
>>> ...
>>>> Do we need to give an initial value just for conversion to work at
>>>> all, or is it only needed as a return in the error case?
>>>>
>>>> Tony
>>>
>>> It is needed for both usages: the initial value when the class is not
>>> default constructible, and the error value when we want this value to be
>>> returned when failure. Now we can not have an exception for the
>>> conversion
>>> to a class that is not default constructible because when we give a
>>> default
>>> value it is also interpreted as the error value. As I said we are mixing
>>> both concepts, which is not good, as both are orthogonal.
>>
>> The is only *one* value provided -- a conversion-failure value. It happens
>> to be used internally for some initialization (for std::stream-based
>> conversions). It's an internal implementation matter and not guaranteed to
>> be that way. What do we achieve by stressing it out?
>>
>> V.
>>
>>
>> _______________________________________________
>> Unsubscribe & other changes:
>> http://lists.boost.org/mailman/listinfo.cgi/boost
>>
>>
>
> Hi,
>
> What does this does?
>
> direction d = convert<direction>::from(str);
>
> Vicente
>
>

Not compile, I guess.
You need to either write a specialization of convert, or maybe convert_traits.
You had to specialize << anyhow.

Maybe the default/error form:
   convert<direction>::from(str, down)
shouldn't compile either (ie don't use error return as init value).

Tony

> --
> View this message in context: http://www.nabble.com/-convert--Now-with-Boost.Parameter-interface.-tp23362838p24407682.html
> Sent from the Boost - Dev mailing list archive at Nabble.com.
>
> _______________________________________________
> Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
>


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