Does string.isNumeric mean that parse!int will not throw?

Stanislav Blinov stanislav.blinov at gmail.com
Thu Feb 20 11:57:59 PST 2014


On Thursday, 20 February 2014 at 19:46:35 UTC, w0rp wrote:

> if (s.length > 0 && s.all!isDigit) {
>      // Never throws now.
>      auto x = parse!int(s);
> }

And what about +/- and U/L suffixes? Or, say, different base 
(i.e. hexadecimal)?

It would be way more beneficial if Phobos' parse (or some 
additional function) returned some kind of Optional. Maybe a D 
implementation of Andrei's Expected<T>?


More information about the Digitalmars-d-learn mailing list