On Sunday, 9 August 2015 at 20:13:38 UTC, ixid wrote:
This seems like a reasonable use but errors, obviously I can do it in many other ways:

    ulong[] result = iota(1UL, 10UL).array;


Error: static assert "Argument types in (ulong) are not all convertible to size_t: (ulong)" C:\D\dmd2\src\phobos\std\array.d 516

Yup, bug. Please file an issue at <http://issues.dlang.org/>.

And while I'm here why do arrays not implicitly cast? ulong is happy to accept uint values but ulong[] will not accept uint[].

That's because the offsets of the elements are different. Reading a ulong means reading 8 bytes. But in a uint[] every element only takes up 4 bytes. So every 2 uint elements would be combined into one ulong. And if the uint[] doesn't have an even number of elements, you'd read beyond array bounds.

You can do that conversion explicitly, but for an implicit conversion that would be too surprising.

Reply via email to