[Issue 7080] New: Chained BigInt.opAssign

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Dec 8 04:27:58 PST 2011


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

           Summary: Chained BigInt.opAssign
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: Phobos
        AssignedTo: nobody at puremagic.com
        ReportedBy: bearophile_hugs at eml.cc


--- Comment #0 from bearophile_hugs at eml.cc 2011-12-08 04:27:56 PST ---
For uniformity with normal integers I'd like this handy assignment to work:


import std.bigint;
void main() {
    BigInt x, y;
    x = y = 1;
}


But with dmd 2.057beta it gives:

test.d(4): Error: template std.bigint.BigInt.opAssign(T : long) does not match
any function template declaration
test.d(4): Error: template std.bigint.BigInt.opAssign(T : long) cannot deduce
template function from argument types !()(void)


I think the problem is solved returning the input argument from both opAssign:

    ///
    T opAssign(T: long)(T x)
    {
        data = cast(ulong)((x < 0) ? -x : x);
        sign = (x < 0);
        return x;
    }

    ///
    T opAssign(T:BigInt)(T x)
    {
        data = x.data;
        sign = x.sign;
        return x;
    }


See also bug 7079.

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