On Tuesday, 5 February 2013 at 15:49:59 UTC, Dan wrote:

- Wouldn't the scenario be exactly the same without ValuationHistory? That is, if I comment out the member _valuationHistory, the goo member is not changed in structure at all, and yet it compiles just fine.

Scenario is the same if there is struct with postblit and const(S) is passed as AA argument. If there is more code involved, the situation can be more complicated.

- Does this mean that "no one" or "very few" developers store structs with postblits as value types in the standard associative array? Maybe I just do things differently than others.

This does not imply such situation, simply there is a problem. You can workaround by

struct DAssociativeArray(Key, Value)
{
    struct Slot
    {
        Value value;
    }
}

struct RC {
    int i;
    void postblit() { i = -5; }
    this(this) const
    {
        void delegate() dg = &postblit;
        dg();
    }
}

void main()
{
    RC rc1 = RC(5);
    RC rc2 = rc1;
    assert(rc2.i is -5);
    DAssociativeArray!(int, const(RC)) goo;
}

Reply via email to