ndslice: convert a sliced object to T[]

Andrea Fontana via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Jun 15 02:32:21 PDT 2016


On Wednesday, 15 June 2016 at 08:56:15 UTC, data pulverizer wrote:
> On Wednesday, 15 June 2016 at 08:53:22 UTC, Andrea Fontana 
> wrote:
>> On Wednesday, 15 June 2016 at 08:25:35 UTC, data pulverizer 
>> wrote:
>>> I guess foreach would not copy the elements? for example:
>>>
>>> foreach(el; slice.byElement)
>>> 		x ~= el;
>>>
>>> But it feels wrong to be doing work pulling elements that 
>>> already exists by using foreach. I feel as if I am missing 
>>> something obvious but can't get it.
>>
>> The question is: why you need to put them inside an array? If 
>> you can, leave them in the lazy range and work on it.
>
> I need this to work with external libraries that only deal with 
> one dimensional arrays.

Then I think the slice.byElement.array is the right solution.


More information about the Digitalmars-d-learn mailing list