Boost logo

Boost :

Subject: Re: [boost] [convert] are you mixing default_value and error_value?
From: Vladimir Batov (batov_at_[hidden])
Date: 2009-07-09 04:31:31

> From: "Gottlob Frege" <gottlobfrege_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?

The user does not provide any initial values. The only value that is
provided is the failure-conversion value:

int i = convert<int>::from(str, 789);

'789' will only be returned if the conversion fails. As

int i = convert<int>::from(str);

does not provide such a conversion-failure value, we have nothing to return
in case of a failure. So, we throw.

Indeed, under the hood that 789 (in #1 case and int() in #2) value happens
to be used for some initialization. However, IMHO it is none of user's


Boost list run by bdawes at, gregod at, cpdaniel at, john at