Boost logo

Boost :

Subject: Re: [boost] [property] interest in C# like properties for C++?
From: Sergey Sadovnikov (flex_ferrum_at_[hidden])
Date: 2009-10-24 13:24:19


Hello, Olaf.

Friday, October 23, 2009 at 8:22:41 PM you wrote:

OvdS> On Fri, Oct 23, 2009 at 5:33 PM, Edward Diener
OvdS> <eldiener_at_[hidden]> wrote:
>> You are not talking about the access syntax of properties, as I define it,
>> so your "Unacceptable"s mean little to me. Of course if the syntax
>> limitations of a property implementation vis-a-vis direct manipulation of a
>> data value is unacceptable to you, then you just wouldn't use it.

OvdS> Don't you agree that string& name = c.name; name.size() is kinda
OvdS> ugly/unusable compared to just c.name->size() (possible) or
OvdS> c.name.size() (not possible, but ideal)?

First case (i. e. c.name->size()) I already implemented in my version
of properties. Properties supports several access interfaces:

1. Like regular datamembers:
string str = c.name;

2. Similar to smart pointers:
string str = *c.name;

3. Function-call like syntax:
string str = c.name();

4. set/get syntax:
string str = c.name.get();

5. Member-access interface:
size_t sz = c.name->size();

Last for cases breaks traditional datameber access inteface. But!
During regular usage in live project it does not matter. I mean that
properties (in such implementation) are another kind of the class
interface. Your are always keeping in mind (almost automatically) what
such kind of member in the public class interface is not usual
datamember and can have specific access rules. It is simple. :)

-- 
Best Regards,
 Sergey                          mailto:flex_ferrum_at_[hidden]

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