How to get element type of a slice?

Ferhat Kurtulmuş aferust at gmail.com
Tue Aug 17 12:27:31 UTC 2021


On Tuesday, 17 August 2021 at 12:26:36 UTC, jfondren wrote:
> On Tuesday, 17 August 2021 at 12:21:31 UTC, Ferhat Kurtulmuş 
> wrote:
>> [...]
>
> This one's not in std.traits:
>
> ```d
> import std.range : ElementType;
>
> struct Point { int x, y; }
>
> unittest {
>     Point[] points;
>     assert(is(ElementType!(typeof(points)) == Point));
> }
> ```

Awesome! Have a great day.


More information about the Digitalmars-d-learn mailing list