On 05/16/2013 08:21 AM, Byron Heads wrote: > On Thu, 16 May 2013 08:11:35 -0500, 1100110 wrote: > >> On 05/16/2013 08:09 AM, Byron Heads wrote: >>> I am working on d-leveldb wrapper (https://github.com/bheads/d-leveldb) >>> and I need to be able to pass blocks of data between D and leveldb API. >>> I am having rouble getting the byte size of dynamic arrays and POD >>> classes. >>> >>> I can get the right size for 1D dynamic arrays, need a way to compute >>> the total size. >>> >>> POD Classes always give me the size of the ref, is it possible? >>> >>> -Byron >> >> >> __traits(classInstanceSize, MyClass); ? > > I missed that one, in my test it returns 29 bytes, > 8 for __vptr > 8 for __monitor > 13 for data > > now I am wondering way a POD has a vtable. Either way its not safe to > store a byte copy in to leveldb
Why not just use a struct? .sizeof gives those accurately. Oh you wanted both... Maybe take a look at vibe's rest interface? It extracts the members of classes and does funny things with them. Can't say I understand it. Over my head... https://github.com/rejectedsoftware/vibe.d/blob/master/source/vibe/http/rest.d or final class MyPodClass {} ? And yeah, if you get stuck, std.traits is a really rich resource. =D Good luck!
signature.asc
Description: OpenPGP digital signature