www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 7080] New: Chained BigInt.opAssign

reply d-bugmail puremagic.com writes:
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 puremagic.com
        ReportedBy: bearophile_hugs eml.cc



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: -------
Dec 08 2011
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7080


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |clugdbug yahoo.com.au
         Resolution|                            |DUPLICATE



*** This issue has been marked as a duplicate of issue 8165 ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 16 2012