Struct initializers and const in 2.009

Dan murpsoft at hotmail.com
Sun Jan 6 21:03:38 PST 2008


You actually managed to make your programs compatible with D 1.x and 2.x !?!?

I spent a good 40 minutes on my source, and ultimately realized it's impossible for me to do so;

version(D_Version2)
  alias const(char)[] const_string;
else
  alias char[] const_string;

Value {
  const Value opIndex(const_string){
    bla bla 
  }
}

You can't alias out the const declaration for the function, and you can't get rid of it in 2.x and still have the program work, let alone have the desired functionality.

Only reason the strings work is 'cause Alan showed me.  : )



More information about the Digitalmars-d mailing list