On Wednesday, 10 August 2016 at 15:07:52 UTC, Ali Çehreli wrote:
On 08/10/2016 02:05 AM, ciechowoj wrote: Better with some mixin magic:mixin template CArray(string symbol, T) { pragma(mangle, symbol) extern extern(C) __gshared mixin ("T[0] _c" ~ symbol ~ ";"); @propertymixin ("T* " ~ symbol ~ "() { return _c" ~ symbol ~ ".ptr; }");} mixin CArray!("tab", int); tab[42] = 42;
This is very tempting to use. The only thing that stops me from doing that is I am unsure if the 'property' tab behaves in all contexts the same way the standard array behaves.
