[Issue 24044] New: Support float opCmp(...) with array

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Jul 11 14:48:42 UTC 2023


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 at puremagic.com
          Reporter: apz28 at 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

--


More information about the Digitalmars-d-bugs mailing list