[Issue 9286] std.conv.parse fails to compile with Nullable

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Jan 9 03:43:27 PST 2013


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



--- Comment #6 from jens.k.mueller at gmx.de 2013-01-09 03:43:24 PST ---
(In reply to comment #5)
> std.traits is purposefully _not_ taking implict conversion into account (doing
> otherwise would cause havoc with template constraints), and isIntegral
> specifically says "Detect whether $(D T) is a built-in integral type." And it's
> not like isIntegral could be made to work for user-defined types, as integral
> types don't have an API specific to themselves. The trait has to know all of
> the types that count as being integral types.

I perfectly agree that isIntegral now conforms to the documentation. Just the
name is misleading.
Why is it impossible to make isIntegral work for user-defined types in the same
way as e.g. isInputRange works?
They do have an API. Just to mention some you use +, -, *, / etc. You just need
to fix this set.

> To do the conversion that you're looking for, just convert to uint first:
> 
>     auto f = to!(Nullable!uint)(to!uint("12"));
> 
> or
> 
>     auto f = Nullable!uint(to!uint("12"));

Can't do this as this happens inside getopt. I pass getopt a Nullable and later
check whether it was actually set by getopt.

-- 
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