Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.
/ druntime Public archive
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion src/object.d
Original file line number Diff line number Diff line change
Expand Up @@ -3375,7 +3375,10 @@ if (!__traits(isScalar, T1))
alias U2 = Unqual!T2;
static assert(is(U1 == U2), "Internal error.");

static @trusted ref R at(R)(R[] r, size_t i) { return r.ptr[i]; }
static if (is(U1 == void))
static @trusted ref inout(ubyte) at(inout(void)[] r, size_t i) { return (cast(inout(ubyte)*) r.ptr)[i]; }
else
static @trusted ref R at(R)(R[] r, size_t i) { return r.ptr[i]; }

// All unsigned byte-wide types = > dstrcmp
immutable len = s1.length <= s2.length ? s1.length : s2.length;
Expand Down Expand Up @@ -3483,6 +3486,22 @@ if (!__traits(isScalar, T1))
compareMinMax!(immutable real);
}

// void[]
@safe unittest
{
void[] a;
const(void)[] b;

(() @trusted
{
a = cast(void[]) "bb";
b = cast(const(void)[]) "aa";
})();

assert(__cmp(a, b) > 0);
assert(__cmp(b, a) < 0);
}

// objects
@safe unittest
{
Expand Down