[Issue 11188] std.math.abs fails for shared, const or immutable BigInt types

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Oct 10 11:23:54 PDT 2013


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



--- Comment #2 from Joseph Rushton Wakeling <joseph.wakeling at webdrake.net> 2013-10-10 11:23:53 PDT ---
(In reply to comment #1)
> Does std.math.abs even work for anything other than built-in types currently? I
> know it should, but I'm skeptical if it does.

It works for regular BigInt, it's just when you qualify that with shared, const
or immutable that it fails.

> In any case, it should take inout arguments since it doesn't (and shouldn't)
> modify them. So this (in theory) should work:
> 
> inout(Num) abs(Num)(inout(Num) x) if ( ... ) {
>     return (x >= 0) ? x : -x;
> }

I'll give that a go and if it works, send a patch to Phobos.  Thanks for the
thought.  Incidentally, shouldn't "in" be sufficient there for the input?

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