[Issue 5543] to!int to see a char as a single-char string

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Dec 21 10:24:13 PST 2012


http://d.puremagic.com/issues/show_bug.cgi?id=5543



--- Comment #18 from bearophile_hugs at eml.cc 2012-12-21 10:24:12 PST ---
(In reply to comment #16)

> Whereas if it threw to begin with you're forced to catch exceptions.

There is no perfect solution. Exceptions are safer than error codes because if
you forget to test for a negative result, your program stops. On the other hand
exceptions are less efficient, less handy to use in nothrow functions, and
often require some try-catch wrapping.

In this enhancement request I was originally asking for an overload of to!(),
this means a solution that throws exceptions when the input is wrong.

Efficiency is not a significant problem for me here because where I need to
convert char digits to numerical digits with max efficientcy I use a '0'
subtraction (or a vectorized version of it). So with this overload of to!() I
was looking for safety.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list