New with alias

tcak tcak at gmail.com
Tue Mar 10 06:09:23 UTC 2020


I write a code as below:

auto result = new char[4];

It allocates memory as expected.



Later I define an alias and do the above step:

alias Pattern = char[4];

auto result = new Pattern;

But compiler says:
Error: new can only create structs, dynamic arrays or class 
objects, not `char[4]`'s



Is this a bug, or `alias` doesn't work how I was thinking?


More information about the Digitalmars-d-learn mailing list