Simplest way to create an array from an associative array which its contains keys and values?

Philippe Sigaud philippe.sigaud at gmail.com
Sun Jan 5 06:55:00 PST 2014


On Sat, Jan 4, 2014 at 1:08 AM, Ali Çehreli <acehreli at yahoo.com> wrote:

> 3) The member rangeFront is needed because Tuple does not have opIndex for
> dynamic indexes. I can do range.front[0] but I cannot do
> range.front[currentIndex].

Is there any plan to add indexing on runtime indices to Tuple? It can
be done, by generating a specific runtime opIndex for Tuple, if the
types held in the tuple have a common type.


CommonType!Types opIndex(size_t index)
{
    // generated code, say Types is 3-element long:
    switch(index)
    {
        case 0:
            return values[0];
        case 1:
            return values[1];
        case 2:
            return values[2];
      default:
            throw new OutOfRangeException(...);
    }
}



More information about the Digitalmars-d-learn mailing list