Boost logo

Boost :

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


On Mar 1, 2010, at 2:48 PM, Zachary Turner wrote:

>
>
> On Mar 1, 2010, at 1:39 PM, Christopher Jefferson <chris_at_[hidden]> wrote:
>
>>
>> On 1 Mar 2010, at 18:24, Germán Diago wrote:
>>
>>> for trivial properties it's the same. But maybe in the future
>>> properties will be extended with some metadata.
>>> anyway, for trivial properties it's the same.
>>
>> I don't understand what your library does. Having your most simple example say it does nothing at all is not helpful!

Where properties are useful is eliminating the need to define "setters/getters" while ensuring that
no one ever gets a direct reference to the actual data. This is critical for multi-threaded programs where
you want to reduce "shared state".

My issue with the approach is that it drastically increases the size of your object and the cost of calling constructors.

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.

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.

Dan

>>
>> Chris
>
> Presumably it should allow you to create read amd write-only properties, for example, with arbitrary getter / setter functions. I would think so anyway, given the description.
>
> 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.
>
> Zach
> _______________________________________________
> 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