I have a struct `A` that stores delegates. The problem is that I'm getting "`Error: closures are not yet supported in CTFE`" if I create an compile-time constant value of type `A`:

```d
struct A
{
    void delegate()[] dg;
}

auto createDelegate(string s)
{
return { s.writeln; }; // Error: closures are not yet supported in CTFE
}

A create()
{
    A a;
    a.dg ~= createDelegate("hello");
    a.dg ~= createDelegate("buy");
    return a;
}


void main()
{
enum a = create(); // If change 'enum' to 'auto' then everything works
    foreach(dg; a.dg)
        dg();
}
```

How can I workaround this and have compile-time object with delegates?

Reply via email to