Thread overview
Convert int[] to custom[]
Dec 14, 2019
SR_team
Dec 14, 2019
JN
Dec 14, 2019
SR_team
December 14, 2019
```
alias custom = Typedef!int;
custom[] arr = [1,2,3];
```
Error: cannot implicitly convert expression [1, 2, 3] of type int[] to Typedef!(int, 0, null)[]

```
alias custom = Typedef!int;
custom[] arr = cast(custom[])[1,2,3];
```
Error: cannot cast expression 1 of type int to Typedef!(int, 0, null)
Error: cannot cast expression 2 of type int to Typedef!(int, 0, null)
Error: cannot cast expression 3 of type int to Typedef!(int, 0, null)



Work only this variant:
```
alias custom = Typedef!int;
custom[] arr = [cast(custom)1,cast(custom)2,cast(custom)3];
```
but this crap
December 14, 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.
December 14, 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