digitalmars.D.learn - idup portable D1/D2
- Frank Benoit (14/14) Mar 25 2009 I want to make code compilable with D1+D2.
- Frank Benoit (10/10) Mar 25 2009 hm, the moment of pressing the "send" button is often enough a moment of
I want to make code compilable with D1+D2. So i thought, i can make version(D_Version2){ } else { // D1 string idup( char[] str ){ return str.dup; } } But this does not work. D1: str.idup; // compile error str.idup(); // OK D2: str.idup; // OK str.idup(); // compile error Ideas?
Mar 25 2009
hm, the moment of pressing the "send" button is often enough a moment of enlightment :) version( D_Version2 ){ mixin("invariant(T)[] _idup(T)( T[] str ){ return str.idup; }"); } else { // D1 String _idup( char[] str ){ return str.dup; } } str._idup(); // compiles with D1+D2
Mar 25 2009