On Sunday, 22 May 2016 at 07:35:32 UTC, Rusty wrote:
I know it's possible to do [explicit object
allocation](http://wiki.dlang.org/Memory_Management#Explicit_Class_Instance_Allocation) on the heap, but I find that quite cumbersome.
So.. is it possible to overload 'new' and 'delete' to not use
GC?
The way to do it is to use emplace() and destroy() instead.
https://p0nce.github.io/d-idioms/#Placement-new-with-emplace
Unique!T, RefCounted!T, and Scoped!T use emplace() internally.
Also, it seems many features of the language rely on GC. Is
there a definitive list of those?
- new
- Appending and concatenating slices
- Homogeneous template parameters void f(
- Some array literals
- Closures that escape
- other features I don't recall
@nogc lets you avoid all of them and is necessary to avoid
unintentional allocations.