Boost logo

Boost Users :

From: Davi de Castro Reis (davicastro_at_[hidden])
Date: 2005-03-17 09:10:30


Hi all,

The question I have is not boost specific (maybe not even boost
related), so if you think it is not appropriate to ask it here, please,
please just tell me.

So, here it goes. Is it possible to find the offset of a class member in
compile time? In runtime, I can get the offset of member m1 in class A
with the code

offset = ((A *)0)->m1

But I want this value in compile time to use in some template
metaprogramming. Is this possible? Since sizeof() is compile time, I
suspect there is a way to do it.

This would come very in hand for a metaprogramming based serialization
library I am working on.

Thanks in advance,
Davi de Castro Reis

If it is not appropriate to ask such questions here, could someone point
me a C++ list where I could ask some advanced questions?


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net