Thread overview | |||||
---|---|---|---|---|---|
|
March 05, 2016 Wrap array into a range. | ||||
---|---|---|---|---|
| ||||
I have to pass an array to a function that accepts an input range. Therefore I need to transform somehow array into an input range. Is there a range that wraps an array in standard library? |
March 05, 2016 Re: Wrap array into a range. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Alexandru Ermicioi | On Saturday, 5 March 2016 at 16:28:51 UTC, Alexandru Ermicioi wrote:
> I have to pass an array to a function that accepts an input range. Therefore I need to transform somehow array into an input range.
>
> Is there a range that wraps an array in standard library?
You just need to import std.array. --Ilya
|
March 05, 2016 Re: Wrap array into a range. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ilya Yaroshenko | On Saturday, 5 March 2016 at 16:35:55 UTC, Ilya Yaroshenko wrote:
> On Saturday, 5 March 2016 at 16:28:51 UTC, Alexandru Ermicioi wrote:
>> I have to pass an array to a function that accepts an input range. Therefore I need to transform somehow array into an input range.
>>
>> Is there a range that wraps an array in standard library?
>
> You just need to import std.array. --Ilya
I suggest that if the compile complains:
T[] has no property front
That one should import std.range since it will import std.array publicly.
Anyway, std.array provides range free functions that work with the Array type making the compiler think arrays are ranges.
Note that this import must be done for the code which checks/utilizes the array, not the code passing the array to a function.
|
Copyright © 1999-2021 by the D Language Foundation