idup portable D1/D2

Frank Benoit keinfarbton at googlemail.com
Wed Mar 25 05:19:46 PDT 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


More information about the Digitalmars-d-learn mailing list