www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 24044] New: Support float opCmp(...) with array

https://issues.dlang.org/show_bug.cgi?id=24044

          Issue ID: 24044
           Summary: Support float opCmp(...) with array
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: druntime
          Assignee: nobody puremagic.com
          Reporter: apz28 hotmail.com

import std.stdio, std.array, std.algorithm;

struct Foo
{
 safe:

    float opCmp(scope const(Foo) rhs) nothrow
    {
        return float.nan;
    }
}

void main()
{
    Foo[] a, b;
    a.length = 1;
    b.length = 1;
    writeln(a > b);
}


getting below error
/dlang/dmd/linux/bin64/../../src/druntime/import/core/internal/array/comparison.d(113):
Error: cannot implicitly convert expression `c` of type `float` to `int`
onlineapp.d(18): Error: template instance
`core.internal.array.comparison.__cmp!(Foo, Foo)` error instantiating

--
Jul 11 2023