Why are void[] contents marked as having pointers?

Vladimir Panteleev thecybershadow at gmail.com
Sun May 31 14:32:42 PDT 2009


On Mon, 01 Jun 2009 00:00:45 +0300, Andrei Alexandrescu <SeeWebsiteForEmail at erdani.org> 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.

-- 
Best regards,
 Vladimir                          mailto:thecybershadow at gmail.com



More information about the Digitalmars-d mailing list