When to use void[] vs. ubyte[] in D
Is there a general rule as to开发者_StackOverflow when I should use void[]
instead of ubyte[]
? Is either preferred?
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.
Check out this discussion:
http://www.digitalmars.com/d/archives/digitalmars/D/learn/272.html
精彩评论