/**
* When mixed in a aggregate this template has for effect to disable the usage
* the $(D new) operator.
*/
mixin template disableNew()
{
@disable new (size_t){return null;}
}
///
unittest
{
// class requiring users to use allocators.
class NotUsableWithNew
{
mixin disableNew;
}
// statically verify that `new` cannot be used.
static assert(!__traits(compiles, new NotUsableWithNew));
}
By Basile, co-invented with Ketmar and Adam