On 2/19/12, Timon Gehr <[email protected]> wrote:
> Concatenation only works if at least one of the types is an array.

Ah, good point. Still can be worked around:

struct Hash(Key, Val)
{
    struct WrapVal(Val)
    {
        Val val;

        auto opCat(Val rhs)
        {
            return [val] ~ rhs;
        }

        alias val this;
    }

    alias WrapVal!Val ValType;

    ValType[Key] aa;

    ValType opIndex(Key key)
    {
        return aa.get(key, ValType.init);
    }

    alias aa this;
}

class Chunk { }
alias Hash!(string, Chunk) ChunkHash;

void main()
{
    ChunkHash chunks;
    Chunk[] tempVar = chunks["CCCC"] ~ new Chunk();
}

Reply via email to