Subject: Re: [boost] [property] interest in C# like properties for C++?
From: Edward Diener (eldiener_at_[hidden])
Date: 2009-10-22 20:45:47
Sid Sacek wrote:
>>> [ Edward Diener wrote: ]
>>> Manipulating a reference property would be done purely through accessing
>>> the property. Accessing a reference property returns a T & or a T const
>>> & depending on whether the property is const or not. In the case where a
>>> T & is returned the reference property is read/write if T itself is not
>>> const, since you can manipulate T through the reference, whereas in the
>>> case where T const & is returned ( or where T & is returns but T is
>>> itself const), the reference property is read only.
> Who says that's how properties work? That just happens to be your version of
> the implementation details.
Of course it is my version of the implementation details. Why would I
explain it that way if it were not.
> I don't think that's how properties have to work at all.
Good for you. Then you should posit an alternative.
In my version value properties do not even have to exist as data
variables either globally/static or members of a class. They can be
synthesized on the fly. Reference properties OTOH have to exist as
backing data somewhere, since a reference to that data is being
returned. If you think, as you mentioned in another post, that
"properties behave just like references" then properties must exist as
backing data somewhere and the whole point of a property setter
implementing a constraint is lost, since one can manipulate any
property directly through the reference. Whereas with value properties (
the return is always a value of the appropriate T type and never a T & )
the only way to change the property is through the setter.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk