New

Creates an object of type T and calls its constructor if necessary.

Description: This is an equivalent for D's new opetator. It allocates arrays, classes and structs on a heap using currently set globalAllocator. Arguments to this function are passed to constructor.

alias New = allocate

Examples

MyClass c = New!MyClass(10, 4, 5);
int[] arr = New!(int[])(100);
assert(arr.length == 100);
MyStruct* s = New!MyStruct;
Delete(c);
Delete(arr);
Delete(s);

Meta