d-dbapi ALPHA-2 released

Christian Kamm kamm.incasoftware at shift-at-left-and-remove-this.de
Mon Jun 11 10:58:18 PDT 2007


Myron Alexander wrote:
> code

If there are no other reasons for it, you could avoid the intervening step
with the Row!(...) temporary struct:

T fetchstruc(T) () {   
  static if (is (T == struct)) {
    T t;
        
    // check if last struct field is bool array 
    // of correct size to store nullflags
    static if(is(typeof(t.tupleof[$-1]) == bool[t.tupleof.length - 1]))
    {
      foreach (i, v; t.tupleof[0..$-1]) {
        t.tupleof[i] = getRowElement!(typeof(t.tupleof[i]))(i);
        t.tupleof[$-1][i] = false; // get correct nullflag
      }                         
    }
    else  // ignore nullflag
    {
      foreach (i, v; t.tupleof) {
        t.tupleof[i] = getRowElement!(typeof(t.tupleof[i]))(i);
      }
    }

    return t;
  } else {
    static assert (0);
  }
}



More information about the Digitalmars-d-announce mailing list