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: nob...@puremagic.com
        ReportedBy: bearophile_h...@eml.cc


--- Comment #0 from bearophile_h...@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: -------

Reply via email to