Convert int[] to custom[]

JN 666total at wp.pl
Sat Dec 14 12:38:18 UTC 2019


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.


More information about the Digitalmars-d mailing list