Boost logo

Boost :

Subject: Re: [boost] [property] interest in C# like properties for C++?
From: Agustín K-ballo Bergé (kaballo86_at_[hidden])
Date: 2009-10-19 13:50:17


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é.-


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk