Explicit Slicing of std.container.Array
ketmar via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sat Jan 24 13:10:29 PST 2015
On Sat, 24 Jan 2015 19:51:30 +0000, Nordlöw wrote:
> On Saturday, 24 January 2015 at 13:59:13 UTC, Tobias Pankrath wrote:
>>> foreach (e; a[].filter!"true") {}
>
> Is a[] a no-op if a is a D normal builtin array/slice?
yes. the following source produces the same machine code regardless of
slicing on `z` with 'dmd -c':
usize test (int[] a) { return a.length; }
int main () {
int[] z = new int[](4);
z[0] = 42;
z[3] = 666;
return test(z[]);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20150124/69389d14/attachment.sig>
More information about the Digitalmars-d-learn
mailing list