Alias New

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

alias New = allocate;

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.

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);