
9 Jul
2009
9 Jul
'09
8:31 a.m.
From: "Gottlob Frege" <gottlobfrege@gmail.com>
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 business. V.