disableNew

When mixed in a aggregate this template has for effect to disable the usage the new operator.

mixin template disableNew () {}

Examples

1 // class requiring users to use allocators.
2 class NotUsableWithNew
3 {
4     mixin disableNew;
5 }
6 
7 // statically verify that `new` cannot be used.
8 static assert(!__traits(compiles, new NotUsableWithNew));
9 
10 // Ok with a custom allocator
11 auto a = construct!NotUsableWithNew();
12 destruct(a);

Meta