Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When to use void[] vs. ubyte[] in D

Tags:

arrays

d

Is there a general rule as to when I should use void[] instead of ubyte[]? Is either preferred?

like image 208
user541686 Avatar asked Aug 13 '11 16:08

user541686


1 Answers

void[] for data that may contain pointers, byte[] for data that's actually just data, like network buffers or files. (I realize Phobos is inconsistent on this)

The reasoning is that the GC scans void[]s for pointers, but not ubyte[]s.

like image 191
FeepingCreature Avatar answered Oct 19 '22 21:10

FeepingCreature