How to get element type of a slice?
Jesse Phillips
Jesse.K.Phillips+D at gmail.com
Sat Aug 21 02:59:39 UTC 2021
On Thursday, 19 August 2021 at 04:03:31 UTC, jfondren wrote:
> On Thursday, 19 August 2021 at 03:32:47 UTC, Jesse Phillips
> wrote:
>>> On Tuesday, 17 August 2021 at 12:33:03 UTC, Ferhat Kurtulmuş
>>> wrote:
>>>> Hey, thank you again but, I don't want an instance of
>>>> Point[] I need:
>>>>
>>>> alias T = Point[];
>>>>
>>>> alias ElementOfPointSlice = .... // element type of T
>>>
>>
> so, what's the problem? This passes tests:
>
> ```d
> import std.range : ElementType;
>
> struct Point { int x, y; }
> alias T = Point[];
> alias ElementOfPointSlice = ElementType!(T);
>
> unittest {
> assert(is(ElementOfPointSlice == Point));
> }
> ```
No issue just trying to give Ferhat a final answer to his
question.
More information about the Digitalmars-d-learn
mailing list