
From: "Vicente BOTET" <vicente.botet@wanadoo.fr> Hi,
I was thinking on the fallback feature a little bit more and I've the impression that we can get it for free. If we accept that we need a no-throw function such as try_convert_to that returns an optional Target we can have the fallback using the optional::get_value_or function
auto r = try_convert_to(*int*)(s); int i = r.get_value_or(fallback); ... I don't know if it is worth adding a function that does all in one
int i = convert_to_or(*int*)(s, fallback);
Vicente, Your suggestion of deploying get_value_or() indeed provides the fallback feature quite easily. However, the original 2 args function Target v = convert_to_or<Target>(s, fallback); does that and more. :-) It does not require the Target type to be DefaultConstructible. Something dear to my heart. :-) V.