
Olaf van der Spek wrote:
On Thu, Oct 22, 2009 at 9:54 PM, vicente.botet <vicente.botet@wanadoo.fr> wrote:
Don't forget, public is public, so part of the contract.
Not everything that compiles is legal or defined behaviour. I'd love to see proper properties support, but I'm afraid that requires language support, otherwise you can't support reference properties.
Of course you can support reference properties along with value properties. It is just very hard, if not impossible, to support both kinds using the same template class. So really one would not a separate template class to support reference properties. 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. But one certainly does not need language support for this. In fact reference properties are very useful for user-defined types as T since the T & ( or T const & )'s data should ideally be manipulated for a T user-defined type through properties within T itself. Thus the property concept can drill down, so to speak, when the T itself is a user-defined type with is own properties.