Boost logo

Boost :

Subject: Re: [boost] the best possible c++ properties (implementation).
From: Daniel Larimer (dlarimer_at_[hidden])
Date: 2010-03-01 16:23:35


On Mar 1, 2010, at 4:00 PM, James Porter wrote:

> On 3/1/2010 2:10 PM, Christopher Jefferson wrote:
>>> Presumably each "int" now has 2 member function pointers. Thus 4 bytes becomes 20 bytes (best case, 64 bit ptrs) and more on
>>> compilers that have bigger member function pointers.
>>
>> What exactly do you mean?
>
> In order for a property ("Age" in the original example) to be able to reference other properties/members of its containing class, it needs a pointer to the object containing it.
>
> But now that I re-read Daniel's message, maybe he's suggesting that you'd have to have:
>
> struct foo {
> int data;
> int (*getter)();
> void (*setter)(int);
> };
>
> which is certainly unnecessary if you're being smart with templates.

My assumption was that the class with the property would want the getter/setter to access other properties of the same class. For example,
say you need to have a mutex around data and thus your setter/getter has something to do.

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
maintain invariants on other properties then I fail to see how your property system would handle it.

>
> - Jim
>
> _______________________________________________
> Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost


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