[Issue 11188] std.math.abs fails for shared BigInt type
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Sep 18 00:17:52 UTC 2017
https://issues.dlang.org/show_bug.cgi?id=11188
b2.temp at gmx.com changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |b2.temp at gmx.com
Summary|std.math.abs fails for |std.math.abs fails for
|shared, const or immutable |shared BigInt type
|BigInt types |
--- Comment #10 from b2.temp at gmx.com ---
Only valid for shared nowadays
import std.bigint, std.math, std.typetuple;
auto foo(T)()
{
T n = -3;
return std.math.abs(n);
}
void main()
{
foreach (T; TypeTuple!(byte, short, int, long, BigInt))
{
assert(foo!T() == 3); // works
assert(foo!(shared(T)) == 3); // fails for BigInt
}
}
The problem is that operator overloads don't accept shared
void main()
{
import std.bigint;
shared(BigInt) i = 0;
assert(i >= 0);
}
--
More information about the Digitalmars-d-bugs
mailing list