Boost logo

Boost :

Subject: Re: [boost] the best possible c++ properties (implementation).
From: Germán Diago (germandiago_at_[hidden])
Date: 2010-03-01 16:49:16

> So long as your setter/getter has no external context then why not just use a public data member?   If the setter/getter of property A needs to.

Because my plan is to add some metadata, probably, but this is another
more long-term goal.

See for the code sample. It has elaborated properties as well. I have
been able to put the Getter and setter pointers as template arguments
as of now (but not in the sample I attached in the mail). Every
non-trivial property has two pointers (one to the getter and one to
the setter) plus the object pointer.

My goal is not to implement the most efficient properties in space,
but to implement the most full-featured ones. It will be as close to
C# properties as I can. The current implementation does not use
std::function anymore, it uses plain pointer to member functions.

All in all, what you have is a property system that can use getters
and setters. To initialize elaborated properties you will need a
pointer to this, and nothing else (the value if you want, but no
function pointers in the arguments since they are passed through

The trivial properties store just the object itself, so they don't
have (as of now) space overhead.

>He alluded to this in the original post but there was no code sample demonstrating, only a code sample for trivial >properties, which dont seem terribly useful.

The code is attached in the mail.

>Best possible properties would have 0 per-instance overhead in either size or construction/destruction. Such a
>solution is possible and I hope to share it with the board soon. But put your mind to work and I am sure you can >figure it out as I did in 30 minutes or less. It does require the use of macros however.

Please, explain me the way to do it. It will be very welcome. Thanks.

Boost list run by bdawes at, gregod at, cpdaniel at, john at