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

           Summary: BigInt bool assign
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            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:13:14 PST ---
For uniformity with normal integers I'd like this D2 program to work:


import std.bigint;
void main() {
    BigInt b = true;
}


But with dmd 2.057beta it gives:

...\dmd2\src\phobos\std\bigint.d(117): Error: operation not allowed on bool 'x'


I think an opAssign similar to this one solves the problem:


    void opAssign(T: long)(T x)
    {
        static if (is(T == bool))
        {
            data = cast(ulong)x;
            sign = false;
        }
        else
        {
            data = cast(ulong)((x < 0) ? -x : x);
            sign = (x < 0);
        }
    }

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

Reply via email to