www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 22521] New: [CTFE] std.experimental.allocator.make and


          Issue ID: 22521
           Summary: [CTFE] std.experimental.allocator.make and dispose are
                    not CTFEable.
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: ttanjo gmail.com

Custom allocators are useful for performance (e.g., std.regex internally uses
its custom allocator)and std.experimental.allocator provides a generic
interface for them: `make` family and `dispose` family.

However, current interface of std.experimental.allocator prevents functions
that use custom allocator from CTFEability.

It would be nice if `make` family and `dispose` family can provide an interface
that enables CTFEability while keeping its flexibility.

Here is a current interface of `make`.
auto make(T, Allocator, A...)(auto ref Allocator alloc, auto ref A args); 

A problem is that it takes a custom allocator as a runtime parameter.
If `make` take a custom allocator as a template alias parameter, we will solve
this issue.

PoC: https://run.dlang.io/is/WYSaLd

Nov 18 2021