Subject: Re: [boost] [convert] are you mixing default_value and error_value?
From: Gottlob Frege (gottlobfrege_at_[hidden])
Date: 2009-07-09 09:23:31
On Thursday, July 9, 2009, Vladimir Batov <batov_at_[hidden]> 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?
> 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?
Maybe it should not be used for initialization at all. Let's say
MyClass has a bad_state setting, that, when set, stops the class from
doing anything, even processing << operators.
So if I pass in bad_state as a default return value, it won't work if
it is internally being used as an init value.
> 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