Comment #0 by dlang-bugzilla — 2018-05-19T17:27:04Z
Created attachment 1696
Draft patch for making alignment a method
Many building block allocators have a line such as:
enum uint alignment = Allocator.alignment;
or:
alias alignment = ParentAllocator.alignment;
This doesn't work when the parent allocator is an opaque class.
Possible solutions:
- Forego use of alignment as a compile-time value, instead treating it as a runtime value everywhere. Rely on compiler optimizations to punch through the layers as needed.
This is probably not feasible as many allocators rely on the underlying types having a predefined, constant alignment. Using ParentAllocator.init.alignment allows hacking around this, though.
Attached is a draft patch towards this approach.
- Declare alignment as an enum/alias iff ParentAllocator's alignment can be read at compile-time. For allocators that require knowing the alignment beforehand, this can be made as an explicit check (to produce a human-readable error message if they are used with e.g. RCIAllocator).
Comment #1 by robert.schadek — 2024-12-01T16:33:48Z