On Monday, 24 March 2025 at 17:39:34 UTC, WhatMeWorry wrote:
```
    void setName(string n) { this.name = n; }

    string name;

    uint[Location] aa;  // associative array

auto rbt = new RedBlackTree!(Node, "a.f < b.f", true); // true: allowDuplicates

You would *think* that this would create a new instance every time that the struct is instantiated.

Unfortunately what it does in fact do, is create a RedBlackTree instance *at compiletime*, emit it into the binary, and assign its reference as the default initializer of the `rbt` field.

I think probably the easiest fix is make Bag a class and assign `new RedBlackTree` in the constructor.

Reply via email to