How to get element type of a slice?
Ferhat Kurtulmuş
aferust at gmail.com
Tue Aug 17 12:34:10 UTC 2021
On Tuesday, 17 August 2021 at 12:32:45 UTC, Paul Backus wrote:
> On Tuesday, 17 August 2021 at 12:21:31 UTC, Ferhat Kurtulmuş
> wrote:
>> Hello folks,
>>
>> Hope everyone is doing fine. Considering the following code,
>> in the first condition, I am extracting the type Point from
>> the slice Point[]. I searched in the std.traits, and could not
>> find a neater solution something like ElementTypeOf!T. Is
>> there any neater solution for it? Thanks in advance.
>
> `typeof(T.init[0])`
>
> Note that `std.range.ElementType` will probably not give the
> result you expect for character arrays (such as `char[]` and
> `wchar[]`), due to autodecoding.
Thank you. This one looks better.
More information about the Digitalmars-d-learn
mailing list