On Wednesday, 8 November 2023 at 16:30:49 UTC, Bienlein wrote:
Hello,

I get the error "`addToBiz(T)(Biz!T biz)` is not an lvalue and cannot be modified" when compiling the code below. Can't find a way how to do it right. Am a D newbie and would appreciate some help.

[...]

    static void addToBiz(T)(Biz!T biz)
    {
        // ...
    }


    int main()
    {
        auto biz = new Biz!int(123);
        spawn(&addToBiz, biz);
    }

This is a really bad error message.

The actual problem here is that you can't take the address of a template without instantiating it first. To make your example work, replace `&addToBiz` with `&addToBiz!int`, like this:

    spawn(&addToBiz!int, biz);

Reply via email to