ndslice: convert a sliced object to T[]
Andrea Fontana via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed Jun 15 00:45:12 PDT 2016
On Wednesday, 15 June 2016 at 07:24:23 UTC, data pulverizer wrote:
> On Wednesday, 15 June 2016 at 03:17:39 UTC, Seb wrote:
>> On Wednesday, 15 June 2016 at 03:11:23 UTC, data pulverizer
>> wrote:
>>> in that case:
>>>
>>> import std.array : array;
>>> int[] x = slice.byElement.array;
>>
>> Are you sure you want to create a _copy_ of your data? In most
>> cases you don't need that ;-)
>>
>>> thanks, now I can go to bed!
>>
>> You are welcome. Sleep tight!
>
> Thanks, I did.
>
> I definitely don't want to create a copy! I thought .byElement
> would provide a range which I assume is a reference am I
> forcing it to copy by using .array?
Yes. You're forcing it to read all elements and copy them in a
new array.
More information about the Digitalmars-d-learn
mailing list