@@ -24,6 +24,7 @@ The implementation never adds roots into the GC.
2424+/
2525struct mir_rcarray (T)
2626{
27+ import mir.internal.utility: isComplex, realType;
2728 // /
2829 package T* _payload;
2930 package ref mir_rc_context context() inout scope return pure nothrow @nogc @trusted @property
@@ -65,19 +66,28 @@ struct mir_rcarray(T)
6566 // / ditto
6667 bool opEquals (Y)(auto ref scope const ThisTemplate! Y rhs) @safe scope const pure nothrow @nogc
6768 {
68- return opIndex () == rhs.opIndex ();
69+ static if (isComplex! T)
70+ return cast (const realType! T[]) opIndex () == cast (const realType! Y[]) rhs.opIndex ();
71+ else
72+ return opIndex () == rhs.opIndex ();
6973 }
7074
7175 // /
7276 int opCmp (Y)(auto ref scope const ThisTemplate! Y rhs) @trusted scope const pure nothrow @nogc
7377 {
74- return __cmp (opIndex (), rhs.opIndex ());
78+ static if (isComplex! T)
79+ return __cmp (cast (const realType! T[])opIndex (), cast (const realType! Y[])rhs.opIndex ());
80+ else
81+ return __cmp (opIndex (), rhs.opIndex ());
7582 }
7683
7784 // /
7885 size_t toHash () @trusted scope const pure nothrow @nogc
7986 {
80- return hashOf (opIndex ());
87+ static if (isComplex! T)
88+ return hashOf (cast (const realType! T[])opIndex ());
89+ else
90+ return hashOf (opIndex ());
8191 }
8292
8393 // /
@@ -295,6 +305,14 @@ unittest
295305 static assert (is (typeof (fs) == Slice! (double * )));
296306}
297307
308+ version (mir_test)
309+ @safe pure @nogc nothrow
310+ unittest
311+ {
312+ import mir.complex;
313+ auto a = rcarray(complex(2.0 , 3 ), complex(4.9 , 2 ));
314+ }
315+
298316package template LikeArray(Range )
299317{
300318 static if (__traits(identifier, Range ) == " mir_slice" )
0 commit comments