How to get element type of a slice?

Ferhat Kurtulmuş aferust at gmail.com
Mon Aug 23 10:10:10 UTC 2021


On Saturday, 21 August 2021 at 02:59:39 UTC, Jesse Phillips wrote:
> 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.

Thank you. I appreciate it.



More information about the Digitalmars-d-learn mailing list