
19 Oct
2009
19 Oct
'09
5:50 p.m.
Peder Holt escribió:
I have implemented a prototype support for properties in C++. It has no space overhead as it manages to deduce the this pointer of the class owning it.
The trick used is the following:
//Find offset of member relative to my_class size_t offset=size_t(&((my_class*)0)->x);
That's derreferencing a null pointer. Its probably what the offsetof macro does anyway, which by the way is restricted to PODs.
Not supported yet: indexed properties operator overloads for properties, e.g. my_class.property*my_class.property will currently fail.
Overloading operators for a property is important, I think its what makes it a "C++ Property". Keep the good work going! Agustín K-ballo Bergé.-