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.


This is not safe because you can change the data.

Andrei

Reply via email to