Convert int[] to custom[]

SR_team dlang at prime-hack.net
Sat Dec 14 12:58:58 UTC 2019


On Saturday, 14 December 2019 at 12:38:18 UTC, JN wrote:
> On Saturday, 14 December 2019 at 10:41:14 UTC, SR_team wrote:
>> Work only this variant:
>> ```
>> alias custom = Typedef!int;
>> custom[] arr = [cast(custom)1,cast(custom)2,cast(custom)3];
>> ```
>> but this crap
>
> import std.conv;
> custom[] arr = [1,2,3].to!(custom[]);
>
> OR
>
> import std.algorithm;
> import std.array;
>
> custom[] arr = [1,2,3].map!(x => cast(custom)x).array;
>
>
> work for me.

thank


More information about the Digitalmars-d mailing list