March 25, 2009 idup portable D1/D2 | ||||
---|---|---|---|---|
| ||||
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? |
March 25, 2009 Re: idup portable D1/D2 | ||||
---|---|---|---|---|
| ||||
Posted in reply to Frank Benoit | 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 |
Copyright © 1999-2021 by the D Language Foundation