Optimal struct layout template?

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Sun Dec 14 10:38:00 PST 2008


dsimcha wrote:
> According to the spec, data stored in structs is guaranteed to be laid out in
> the order specified in the source code.  While this is necessary in some
> low-level code, I have a use case where I need to pack structs as efficiently
> as possible.  These structs are to be stored in an array, and for efficiency
> reasons I want to store them directly rather than storing pointers, so using
> classes is out of the question.  Does anyone know how to write a template
> that, given a tuple of types, will reorder the tuple so that it will produce
> the optimal struct layout?  I don't care, at least for now, if it assumes
> x86-32/DMD instead of handling the more general case.

I don't have such code, but if anyone wrote something, it sounds like a 
terrific addition to Phobos.

Andrei



More information about the Digitalmars-d mailing list