OK first and foremost, performance is most important here so I doubt a map would work. I have a list of structs (about 16 of them) like
struct A { ... };
struct B { ... };
...
each are different and each are of different sizes.
I'm wondering what elegant way we might be able to do something along the lines of:
char BufferA[sizeof(struct A)];
char BufferB[sizeof(struct B)];
then write some method or mapping to return BufferA if you are working with struct A. Speed is definitely the most important, I imagine using templates would help but I'm not sure it the whole thing can be templatized.
Update*** Sorry for not being clear, the buffers are all pre-allocated. I just need a very fast way to get the proper Buffer given a struct type.
Update 2*** Sorry for not specifying, alignment is an important trait here and I do in fact byte-align each struct with #pragma pack(push, 1)
With
g++ -O2
the code above generates just a fixed memory write operation infoo
.