On Monday, 7 January 2013 at 15:01:27 UTC, Gor Gyolchanyan wrote:I'm afraid the only viable solution right now is to implement your own AA type as a struct with overloaded operators (which is in fact what the built-in AAs are lowered to as well).
How can I have an associative array, which uses a custom allocator?
There are two downside to this, though - besides, of course, the fact that you need a custom implementation:
- You cannot pass your type to library functions expecting a built-in associative array.
- You lose the convenient literal syntax. This could be fixed in the language, though, by providing a rewrite to a variadic constructor of user types for array/AA literals, thus eliminating the need for GC allocations (gah, another thing I just need to find the time to write up a DIP for…).
David