On Mon, 01 Jun 2009 02:18:46 +0300, Andrei Alexandrescu <[email protected]> wrote:
> Vladimir Panteleev wrote: >> On Mon, 01 Jun 2009 00:00:45 +0300, Andrei Alexandrescu >> <[email protected]> wrote: >> >>> const(ubyte)[] getRepresentation(T)(T[] data) >>> { >>> return cast(typeof(return)) data; >>> } >> This is functionally equivalent to (forgive the D1): >> ubyte[] getRepresentation(void[] data) >> { >> return cast(ubyte[]) data; >> } >> Since no allocation is done in this case, the use of void[] is safe, >> and it doesn't instantiate a version of the function for every type you >> call it with. I remarked about this in my other reply. >> Which is why I wrote "forgive the D1" :) I've yet to switch to D2, but it's obvious that the const should be there to ensure safety. -- Best regards, Vladimir mailto:[email protected]
