On 09.12.2013 23:03, seany wrote:
yet another array question :

I have defined :

alias string[] surrealNum_segments;
alias string[string] surrealNum_segments_withID;
surrealNum_segments_withID BAR;

Is there a built in function FOO, such that i could also write:

FOO(surrealNum_segments) BAR;

instead of

surrealNum_segments_withID BAR;

i.e. that will return an Associative Array type with string keys , with an array
as argument?


import std.range;

alias string[] surrealNum_segments;
alias ElementType!surrealNum_segments[string] surrealNum_segments_withID;

Or, if you don't like writing all that (say, you have 1e8 array types you want ID versions of):

template FOO(T : U[], U) {
    alias U[string] FOO;
}

alias FOO!surrealNum_segments surrealNum_segments_withID;

But no, there is no built-in function of this kind.

--
  Simen

Reply via email to