Add A1.allocate() template to allocate struct/class instances

This commit is contained in:
Josh Holtrop 2023-06-10 10:30:56 -04:00
parent 40ff805f7d
commit 3e32802862

View File

@ -50,4 +50,15 @@ struct A1
return cast(void *)address; return cast(void *)address;
} }
/**
* Allocate memory to store an instance of a given type.
*
* @return Address of allocated memory. This address will always be aligned
* to a multiple of 16 bytes.
*/
public static T * allocate(T)()
{
return cast(T *)allocate(T.sizeof);
}
} }